I have my activity registered as Intent filter (plaintext) and have the issue with receiving multiple intents. This is my situation:
- I open email client -> mark some text -> press “Share button” and choose my activity which is correctly listed (as it is registered as intent filter for such action)
- My activity opens and I can clearly see that intent has correct values in its EXTRA_TEXT (marked text from email)
- So far so good…but now, if I press HOME button (which closes my Activity and seems to call onStop()) -> then I open email client again -> mark some DIFFERENT text -> press “Share button”, then suddenly my activity opens (I would expect the list of available activities to choose from again) and received intent contains the ORIGINAL text and not the newly marked one in its EXTRA_TEXT.
What am I missing here? How to receive new content via intent this way? Do I need to somehow invalidate previous Intent?
I have to say that using “BACK” instead of “HOME” button works correctly and new intent contains newly marked text as expected. What’s the difference here?
I get my Intent this way:
intent = getIntent();
intentAction = intent.getAction();
if (intentAction.equals(Intent.ACTION_SEND) && intent.hasExtra(Intent.EXTRA_TEXT)) {
Bundle bundle = intent.getExtras();
Thanks
Try setting your Activity launchMode to “singleTop” then implement…
The
Intentpassed in to that method should be the new one.See the docs for onNewIntent
EDIT: For future readers – based on the comments below, it seems the documentation may be incorrect and launchMode should be “singleTask” and not “singleTop”.