Android app crashes when calling any explicit inte

2019-01-29 08:17发布

问题:

I have compileSdkVersion and targetSdkVersion 23 and testing on Samsung galaxy s3. But whenever i open any third party app (explicit intent) like camera/gallery app or share intent (gmail, email) or dialer app and comeback to my app by pressing back button or (in case of camera/gallery app by selecting picture). App restarts from MainAcitivty (maybe it is getting crashed but it does not show any exception in logcat). Here is how i open intents:

Call/Dial:

Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + phone));
context.startActivity(callIntent);

Gallery:

Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, GALLERY_PIC_REQUEST);

Share:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
context.startActivity(Intent.createChooser(intent, dialogHeaderText));

This issue is only coming in Samsung s3. I have tested all above functionalities on Google nexus 5, Huawei Honor 4C and Samsung galaxy s5 it is working fine. Any help?

回答1:

Every mentioned intent should have a callback mechanism, it is really strange in Samsung S3's case where I have to face it. I have searched a lot but didn't find anything.

Somehow, I have seen an option in Developer Options titled as Do not keet activities which destroys every activity of user as soon as possible when checked. Please make sure that it is unchecked.

I have fixed it for Samsung S3 with Android version 4.3 and found that this option in many devices and Android OS versions

Please follow these steps:

Android version 4.3 (Samsung galaxy S3):

  1. Go to Settings >> More (Tab) >> Developer Options >> Do not keep activities
  2. Make sure this option is unchecked

General:

  1. Go to Settings >> Developer Options >> Do not keep activities
  2. Make sure this option is unchecked

Hope it will work :)