Sidious911
Sidious911

Reputation: 73

Android: Keep Notification active

in this project I'm working on, there are a bunch of alarms that are created, and when they go off this is what I have currently happening..

  1. Alarm Goes off

  2. Notification is put in the status bar

  3. When user selects the notification it takes them to a specific Activity in the app to handle the notifications that are currently active

  4. As long as there are un-handled notifications, the notification stays in the Status bar

Now the problem with this, is that when the user selects the alarm from the notification centre, it stays there, but it becomes 'dead', if the user leaves the app, and then clicks that notification again, it wont take the user back into the App, this is what LogCat is saying...

StatusBar - Sending contentIntent failed: android.app.PendingIntent$CanceledException
InputManagerService - Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44f94258

I'm coming up dry with a solution that I can get to solve this problem... Anyone else dealt with this issue?

Upvotes: 0

Views: 1046

Answers (1)

Someone Somewhere
Someone Somewhere

Reputation: 23787

Answer: the requestCode and the Notification ID must match, see my use of iAlertUniqueID below :

notification.contentIntent = PendingIntent.getActivity(context, iAlertUniqueID, targetActivityIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
notificationMgr.notify(iAlertUniqueID++, notification);

the iAlertUniqueID is just a static int (not final!) in my class that extends BroadcastReceiver

Upvotes: 1

Related Questions