I have an Activity that is a single task so I guess on create only gets called once. I want to pass some parameters from another activity. using Intent, i am putting extras but when I read them in the single activities onResume, the data is not there.
I need a way to pass data to a single task activity or restart it.
edit
To clarify. The problem is my activity uses Single Task as a launch mode in the manifest. I think this means oncreate only gets called once which is why i am trying to get the parameters in onResume.
When I resume my single task activit, I am unable to get any params added to the intent in the previousd activity because it does not start it but simply resume it
Use onNewIntent() with single-instance Activity. Calling getIntent() in onResume() for a single-instance Activity will return the Intent that originally started the Activity, not the Intent that the Activity just received. To ensure that getIntent() always returns the last-received Intent in a single-instance Activity, use setIntent() to store the last-received Intent.
This is documented in the reference documentation for onNewIntent()
if you are trying to pass data to an activity that was started with single task and the activity is currently up then you need to override onNewIntent when a new intent comes into that activity this is where it goes
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