Not Getting Able To Call Onactivityresult Method
Solution 1:
This is because, you may not be getting RESULT_OK. Always first check for request code and inside that check for result code. If you are retrieving image from gallery, try following code inside onActivityResult():
if (requestCode == TAKE_PICTURE_GALLERY) {
if (resultCode == RESULT_OK) {
finalUriselectedImage= data.getData();
final String[] filePathColumn = { MediaStore.Images.Media.DATA };
finalCursorcursor= getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
finalintcolumnIndex= cursor
.getColumnIndex(filePathColumn[0]);
finalStringfilePath= cursor.getString(columnIndex);
cursor.close();
}
}
And use the filePath wherever you want. I hope this solves your problem. Thank you :)
UPDATE: Use this code to start your gallery activity:
imagePathURI = Uri.fromFile(newFile(<your image path>));
finalIntentintent=newIntent(Intent.ACTION_PICK, imagePathURI);
intent.setType("image/*");
intent.putExtra(MediaStore.EXTRA_OUTPUT, imagePathURI);
startActivityForResult(intent, TAKE_PICTURE_GALLERY);
When you want to retrieve image from gallery, the MediaStore.EXTRA_OUTPUT refers to The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video. So here, you have to pass the image path where u'll receive your image.
imagePathURI = Uri.fromFile(new File(<your image path>));
// here a file will be created from your image path. And when you'll receive an image, u can access the image from this image path.
Post a Comment for "Not Getting Able To Call Onactivityresult Method"