sunil
sunil

Reputation: 9681

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

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 an Activity that is singleTask and needs to be updated on certain values?

Upvotes: 1

Views: 628

Answers (2)

Nikolay Ivanov
Nikolay Ivanov

Reputation: 8935

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

Upvotes: 3

Vit Khudenko
Vit Khudenko

Reputation: 28418

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.

Upvotes: 0

Related Questions