I have an activity for handling deeplink which is a browsable activity
suppose user clicks a link on another app and my browsable activity handles that intent
and start the app, , then user minimise the app by pressing back button
class code for handling intent data
Uri link = getIntent().getData();
if user reopen app from running tasks getIntent() still have data
onDestroy method of browsable activity
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
setIntent(null);
}
setIntent(null) not working
so my question is how can i remove data from intent permanently
I am a little late on the answer here but I was dealing with a similar issue and found a solution. The reason you are still seeing data in the intent is because your app was originally started with an intent that contained data. That original intent is stored somewhere in Androids' ActivityManager and is immutable, to my understanding. When user reopens the app from "recent tasks", Android uses that original intent to recreate the application.
There is a workaround to this, however. In your apps onCreate() method, you can check to see if the Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY is set, which would allow your app to distinguish if it is being started from "recent tasks" or not, and therefore, you can avoid using the data contained in the intent.
Putting the following snippet in your onCreate() method would return true
if the app is being opened from "recent tasks"
(getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0)
you have to remove data one by one key. i think you can't remove all data with one line.
if you want to remove specific key than you should use ==> getIntent().removeExtra("key");
or
getIntent().setAction("");
it will remove your data.
for more ==> Clearing intent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With