As described in this tutorial I added my app to the share list. This works great as long as the share activity isn't started. But if the share activity is currently opened and the user clicks on the Home Button, then opens the gallery, then shares a picture the getExtras() Bundle of the Intent is null. Here is my AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
And the method I call in OnResume of my Activity:
Bundle extras = getIntent().getExtras();
if (extras != null) {
Object o = extras.get(Intent.EXTRA_STREAM);
if (o != null) {
Uri imageUri = (Uri) o;
}
}
Does somebody have a similiar problem, or why is the Bundle null if the activity is only Restarted and Resumed?
The problem was that I've set android:launchMode="singleTask"
in the manifest file for my activity and I've set the Intent.FLAG_ACTIVITY_SINGLE_TOP
for starting the intent. This was the reason the Activity didn't get recreated. I removed both and it now works.