how to get src og imageview in android

I am taking a picture from android phone camera and placing it on imageview. now I want to take that src of imageview so that I could upload it to server. How can I take src of imageview?

Here is my code

public class CameraActivity extends Activity implements View.OnClickListener {
ImageView iv;
Button bCapture, bSetWall;
Intent i;
int CameraResult = 0;
Bitmap bmp;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initialize();
    InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
    bmp = BitmapFactory.decodeStream(is);
}

private void initialize() {
    iv = (ImageView)findViewById(R.id.ivCamera);
    bCapture = (Button)findViewById(R.id.bCapture);
    bSetWall = (Button)findViewById(R.id.bSetWall);
    bCapture.setOnClickListener(this);
    bSetWall.setOnClickListener(this);
}

public void onClick(View v) {
    switch(v.getId()) {
    case R.id.bCapture:
        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(i, CameraResult);
        break;
    case R.id.bSetWall:
        try {
            getApplicationContext().setWallpaper(bmp);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        break;
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        iv.setImageBitmap(bmp);
        //String v = iv.getTag().toString();
        //Toast.makeText(getApplicationContext(), v, Toast.LENGTH_LONG).show();
    }
}


}

Answers


convert the bitmap into byte array and send it to the server

Bitmap bmp = intent.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

It is possible to Upload Image View Without save in sdcard or phone Location store. if you want to save image after take picture from camera then you need to convert image view in bitmap and save it in sdcard. Again you need to convert sdcard image in bitmap to upload it server.

Link1

Link

thanks


Need Your Help

How to process AJAX requests more securely in PHP?

php ajax flash security actionscript

Ok, so I want to send AJAX requests to my website from my Flash games to process data, but I don't want people downloading them, decompiling them, then sending fake requests to be processed, so I'm

'Your credentials did not work' in MS Azure

azure-virtual-machine

I just created an Azure VM using the Windows 8.1 image in the Marketplace. During the creation process I provided a username and password.