Reputation: 679
I am using push notification in our apps, when i receive push notification in notification center, then if i click that notification its redirecting correctly to that particular html page. But when i receive more than one push notification, if i click any other than first notification it will not redirecting, only the message first appear in the notification center list only redirecting. How to redirect every message in notification center android. Below is the code which is used to redirect in android.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras != null) {
super.loadUrl("file:///android_asset/www/homePage.html");
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
}
Upvotes: 0
Views: 350
Reputation: 14840
The problem is that your activity is already created after the first notification is clicked, so onCreate() is not called when the second notification is clicked.
You need to set android:launchMode="singleTop"
for your activity in AndroidManifest.xml, and override onNewIntent.
See Activity#onNewIntent for details.
Upvotes: 2