I have two activity in my application(MainActivity and CheckActivity).
MainActivity Intent to CheckActivity and in CheckActivity Intent to Gallery Application for choose image.
But when return from Gallery Application it always return to MainActivity.
How can I return to CheckActivity when return from Gallery Application.
This is my code.
MainActivity.java
Intent intent = new Intent(this, CheckActivity.class);
startActivityForResult(intent, 1);
CheckActivity.java
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
It's always return onActivityResult in MainActivity.java and requestCode = 1.
Thank you very much.
I think your problem is here
Intent intent = new Intent(this, CheckActivity.class);
startActivityForResult(intent, 1);
Instead of these lines you use
Intent intent = new Intent(this, CheckActivity.class);
startActivity(intent);
Try this:
Intent intent = new Intent(this, CheckActivity.class);
startActivity(intent);
i think you put finish() into your CheckActivity after
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
finish();
if you remove finish() it will work fine...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.