Moti Bartov
Moti Bartov

Reputation: 3592

Get intent from Android onNewIntent on later timing

Is it possible to retrieve the Intent which came in onNewIntent on a later timing?

For example, lets assume that I have a LiveData Observer in my Activity or Fragment, and when onChange is called I want to check if there was a new Intent earlier, with some content in it which is different then the original Intent that launched the Activity?

I don't want to keep a class member variable which holds the new Intent..

Does such thing possible?

Upvotes: 0

Views: 86

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

I don't want to keep a class member variable which holds the new Intent.

You do not have much of a choice.

Is it possible to retrieve the Intent which came in onNewIntent on a later timing?

Only if you override onNewIntent() and store the Intent that you get somewhere.

when onChange is called I want to check if there was a new Intent earlier, with some content in it which is different then the original Intent that launched the Activity?

For this, you could override onNewIntent(), compare the content with that from the original Intent (getIntent()), store the results of that comparison in a class field, and then reference that class field in onChange.

Upvotes: 0

Related Questions