开发者

How to make single instance of Activity with different data passed through Intents in Android?

开发者 https://www.devze.com 2023-01-28 16:43 出处:网络
I want to make an Activity which should be created only once and then it should be updated based on certain values. First I tried to pass data through Intent but since I have made that activity as sin

I want to make an Activity which should be created only once and then it should be updated based on certain values. First I tried to pass data through Intent but since I have made that activity as singleTask it do not get the new Intent object and uses the previous one.

What can be the way of passing the data to开发者_StackOverflow中文版 an Activity that is singleTask and needs to be updated on certain values?


If your activity is singleTask, you need to handle new intents in onNewIntent method


What entity generates the new values? If it is a Service then your Activity can establish a communication channel, so the Service can notify the Activity with new data.

More info here.

0

精彩评论

暂无评论...
验证码 换一张
取 消