Reputation: 143
I'm trying to have my notification builder call only OnResume()
upon the Intent being fired, similar to when the user chooses the app from background running apps. I've tried numerous flags, but I am not getting the result I desire.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
Intent intent = new Intent(this, MainActivity.class);
intent.setAction("OPEN_TAB_CONTACTS");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
mBuilder.setSmallIcon(R.drawable.antartica7);
mBuilder.setContentTitle("Notification Alert, Click Me!");
mBuilder.setContentText("Hi, This is Android Notification Detail,WEWWW!");
mBuilder.setContentIntent(pIntent);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// notificationID allows you to update the notification later on.
mNotificationManager.notify("newmessage", 1, mBuilder.build());
I have tried adding
android:launchMode="singleInstance"
and
android:launchMode="singleTask"
to the AndroidManifest as well.
Upvotes: 0
Views: 98
Reputation: 143
Since no flags were working, I instead check what the Intent action is manually.
Added this to onCreate()
:
if(getIntent().getAction() != null) {
if(getIntent().getAction().equals("OPEN_TAB_CONTACTS")) {
System.out.println("Pending intent called");
} else {
//normal onCreate
}
}
Upvotes: 1