I have four image views in my screen and capture images from camera and displayed in it, now i want to upload those images into the server. So i have used the below code to get the path of those but it's through the exception. Is there any possible to upload the images into the server from image view which is capture from camera(without store the images into the memory).
if (requestCode == 1&& resultCode == RESULT_OK)
{
Bitmap photo = (Bitmap) data.getExtras().get("data");
purchase_Img_1.setImageBitmap(photo);
Uri tempUri = getImageUri(getApplicationContext(), photo);
File finalFile = new File(getRealPathFromURI(tempUri));
}
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
public String getRealPathFromURI(Uri uri) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
return cursor.getString(idx);
}