Problem: I am getting camera intent's data null in onActivityResult(int requestCode, int resultCode, Intent data)
in Samsung S3. But working well on some other devices. I customized my code for getting data and searched this issue in web but nothing found useful.
Code :
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == TAKE_CAMERA && data != null && data.getData() != null)
else if (requestCode == TAKE_CAMERA) {
if (resultCode != RESULT_OK) return;
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(tempFileUri, "image/*");
intent.putExtra("outputX", 90);
intent.putExtra("outputY", 90);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
startActivityForResult(intent, CROP_CAMERA);
} else if (requestCode == CROP_CAMERA && data != null) {
Bitmap photo = data.getExtras().getParcelable("data");
try {
FileOutputStream out = new FileOutputStream(tempFileUri.getPath());
photo.compress(Bitmap.CompressFormat.JPEG, 90, out);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (photo != null) {
imagePhoto.setImageBitmap(photo);
<my code>
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…