I am sending a booking id with the intent, then the page with detail information should refresh with the data related to that booking id. The problem is that if the user is at the detail page and she gets a notification, the data is not refreshed.
The problem is happening when I add launch mode as SINGLETASK. This is the intent code:
Intent intent = new Intent(getApplicationContext(), MyJobsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("idIs", bookingId);
intent.setAction(bookingId);
pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
I've tried with a couple of different Intent's flags, but it didn't work either:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
and
PendingIntent.FLAG_CANCEL_CURRENT
Please override onNewIntent()
method in your MyJobsActivity
class. and do collect the intent data as below:
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
// you can collect the intent data from this intent and
// refresh your MyJobsActivity.
}
onNewIntent()
is called for activities that set launchMode to "singleTop" in their package, or if a client used the Intent#FLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent)
. In either case, when the activity is re-launched while at the top of the activity stack instead of a new instance of the activity being started, onNewIntent() will be called on the existing instance with the Intent that was used to re-launch it.
Please read the documentation for more info on this.