I need to take photos in my application, this is the core codes:
tigger:
mPhotoToBeUpload = new File(mImageBasePath, System.currentTimeMillis() + ".jpg");
try {
mPhotoToBeUpload.mkdirs();
mPhotoToBeUpload.createNewFile();
} catch (IOException e) {
Log.e("xx",e.getMessage());
}
Uri outputFileUri = Uri.fromFile(mPhotoToBeUpload);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, Result_Code_Camera);
Result handler:
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
if (resultCode == RESULT_OK) {
Bitmap photoTaken = BitmapFactory.decodeFile(mPhotoToBeUpload.getAbsolutePath());
mImageView.setImageBitmap(photoTaken);
} else
}
However I found that these codes work in some devices but not in some others.
For example, they does not work in Nexus 4 and Nexus5.
While I saythey does not work,I mean that after I take a picture, and hit the OK
button, I cannot get back to the previous activity:
It have no effect when I hit the OK
(the icon inside the red circle).
What is the problem?
Upadte:
private final String mImageBasePath = Environment.getExternalStorageDirectory() + File.separator + IConstant.Application_Folder + File.separator + "photos";
mPhotoToBeUpload = new File(mImageBasePath, System.currentTimeMillis() + ".jpg");
Result: mPhotoToBeupLoad=/storage/emulated/0/myapp/photos/1395287647386.jpg