0
I have the user Activity, and in it I call the camera using startActivityForResult, but when taking the photo, it goes to Main Activity. How can I call the camera and return to the same user Activity? Details: On Main Activity, I use the startActivityForResult method to return other data. Follow camera call code in Activity User:
public void callIntentImgCam(View view){
File file = new File(android.os.Environment.getExternalStorageDirectory(), "img.png");
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, IMG_CAM);
}
Follow code return in Activity User:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
File file = null;
if(data != null && requestCode == IMG_SDCARD && resultCode == RESULT_OK){
Uri img = data.getData();
String[] cols = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(img, cols, null, null, null);
cursor.moveToFirst();
int indexCol = cursor.getColumnIndex(cols[0]);
String imgString = cursor.getString(indexCol);
cursor.close();
file = new File(imgString);
if(file != null){
wd.getImage().setResizedBitmap(file, 300, 80);
wd.getImage().setMimeFromImgPath(file.getPath());
}
}
else if(requestCode == IMG_CAM && resultCode == RESULT_OK){
file = new File(android.os.Environment.getExternalStorageDirectory(), "img.png");
if(file != null){
wd.getImage().setResizedBitmap(file, 80, 300);
wd.getImage().setMimeFromImgPath(file.getPath());
}
}
if(wd.getImage().getBitmap() != null){
imageView.setImageBitmap(wd.getImage().getBitmap());
}
}
Is the main Activity calling the Activity user with startActivity or startActivityForResult? See if the Activity user is being destroyed.
– ramaral
Main Activity calls user with startActivity. But thank you so much for the tip to check if Activity isn’t being destroyed; what was really happening on onPause.
– Fabricio Chaves Jorhge