Issue
I'm trying to use MediaStore.ACTION_IMAGE_CAPTURE
intent to take a profile photo.
The code that starts the intent:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File myPicture = new File(OfflineApp.getAppContext().getFilesDir() + "/" + getResources().getString(R.string.contact_photos_dir), getResources().getString(R.string.my_photo_file_name));
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(myPicture));
startActivityForResult(cameraIntent, REQUEST_CODE_TAKE_PHOTO);
And the onActivityResult part:
case REQUEST_CODE_TAKE_PHOTO:
if (resultCode == RESULT_OK) {
String path = new File(OfflineApp.getAppContext().getFilesDir() + "/" + getResources().getString(R.string.contact_photos_dir), getResources().getString(R.string.my_photo_file_name)).getAbsolutePath();
ContactManager.getInstance().updateMyImage(path);
}
break;
However, the result code is always RESULT_CANCELED
, only if I provide MediaStore.EXTRA_OUTPUT
, even if the file doesn't exist.
Solution
Okay. Found the problem.
Since Camera Intent is launching the Camera app, it has no access to my apps file folder. Fixed it by passing an external folder file and copying it to my local folder.
Cheers.
Answered By - Eitan F
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.