Is possible to set more than one intent for be launched when, in example, the user clicks an notification.
Let me explain my concrete problem:
I have an app with notifications. Each notification open a different Activity (with different extras too).
Now I want to extract info about the notifications usage. So, every time a notification gets open I'd like to launch a Service with some extras.
I'd like to implement that without modifying the existing activities, since they are not "guilty" of the change.
Ideally the pseudocode could be something like that:
Intent originalActivityIntent=...;
Intent notificationsAnalyticsIntent=getRegisterNotificationClick(notificationId,username);
PendingIntent pi= PendingIntent.multiple(
context,
originalActivityIntent,
notificationsAnalyticsIntent)
Having both intents launched when the notification is clicked.
Writting some kind of service/broadcast receiver could be pretty complex since I would need to handle the different params for each Activity.
Any ideas of how to keep this clean?
No.
The way we solved it is that every Activity in out app extends from some base activity and in each notification we pass an extra in the intent that the base activity handle it.
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