Intent Extras Remain The Same Even When Updated
I am trying to pass a small bit of text between Activity instances using an Intent with extras. This seems to work fine whenever I navigate between them using the back button or na
Solution 1:
I remember running into this issue once, we solved it by either adding Intent.FLAG_ACTIVITY_CLEAR_TOP to the intent you are sending:
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
or by implementing the following method into the activity you're intent is launching:
@OverrideprotectedvoidonNewIntent(final Intent intent) {
super.onNewIntent(intent);
this.setIntent(intent);
}
I'm not 100% sure what fixed it again, believe it was adding the onNewIntent method. Good luck and let us know.
Solution 2:
as @Lauw says :
protectedvoidonNewIntent(Intent intent) {
super.onNewIntent(intent);
this.setIntent(intent);
}
this.setIntent(intent);
This line solved the problem for me.
Solution 3:
Also removing intent extras with intent.removeExtra("key")
can help to update incoming new extras.
This approach helped for my case, when I was trying to launch app A from app B. Everything worked when app A wasn't opened, but when app A was already opened, I had to use the removeExtra
method to get the updates.
Post a Comment for "Intent Extras Remain The Same Even When Updated"