Java – Android deletes data from getintent

I have an activity dealing with deeplink, which is a browsable activity

Suppose a user clicks a link on another application and my browsable activity handles the intent

And start the application, and then the user minimizes the application by pressing the back button

Class code for processing intent data

Uri link = getIntent().getData();

If the user reopens the application from the running task, getintent () still has data

Ondestroy method to browse the activity

@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
setIntent(null);

}

Setintent (null) does not work

So my question is how to permanently delete data from the intent

resolvent:

My answer here is a little late, but I am dealing with similar problems and finding a solution. The reason why you still see data in the intention is that your application was originally started with the intention of containing data. According to my understanding, the original intention is stored in the activitymanager of Android and is immutable. When the user reopens the application from "recent tasks", Android will use the original intent to recreate the application

However, there is a solution. In your application oncreate() method, you can check whether intent.flag is set_ ACTIVITY_ LAUNCHED_ FROM_ History, so that your application can distinguish whether it started from the "recent task", so you can avoid using data included in the intention

If you open the application from recent tasks, putting the following fragment into the oncreate() method will return true

Invalid Sign

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>