"how to get path of captured image in android" Code Answer's
You're definitely familiar with the best coding language Java that developers use to develop their projects and they get all their queries like "how to get path of captured image in android" answered properly. Developers are finding an appropriate answer about how to get path of captured image in android related to the Java coding language. By visiting this online portal developers get answers concerning Java codes question like how to get path of captured image in android. Enter your desired code related query in the search bar and get every piece of information about Java code related question on how to get path of captured image in android.
how to get path of captured image in android
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
knop.setVisibility(Button.VISIBLE);
// CALL THIS METHOD TO GET THE URI FROM THE BITMAP
Uri tempUri = getImageUri(getApplicationContext(), photo);
// CALL THIS METHOD TO GET THE ACTUAL PATH
File finalFile = new File(getRealPathFromURI(tempUri));
System.out.println(mImageCaptureUri);
}
}
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
public String getRealPathFromURI(Uri uri) {
String path = "";
if (getContentResolver() != null) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
path = cursor.getString(idx);
cursor.close();
}
}
return path;
}
Source: stackoverflow.com
All those coders who are working on the Java based application and are stuck on how to get path of captured image in android can get a collection of related answers to their query. Programmers need to enter their query on how to get path of captured image in android related to Java code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to get path of captured image in android for the programmers working on Java code while coding their module. Coders are also allowed to rectify already present answers of how to get path of captured image in android while working on the Java language code. Developers can add up suggestions if they deem fit any other answer relating to "how to get path of captured image in android". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to get path of captured image in android resolved professionally and stay updated to the latest Java updates.