problem with Notification (PendingIntent)

Put your problem here if it does not fit any of the other categories.

problem with Notification (PendingIntent)

Postby sgom » Thu Oct 30, 2008 7:03 pm

Hello guys!

I have a problem with notifications (SDK 1.0)

I have wrote an application that, when an event occurs, prepare a notification and puts it on the status bar.
Each of these notifications should start different instances of the same Activity (a simple activity that shows some information).
The activity receives with the data to show also the integer value to use to dismiss the notification that started it.
Let's call this Activity "show".

Here is the problem: let's say i prepare a notification that should launch my activity "show" with data "first" and put it on the status bar.

Now I prepare a second notification that should launch "show" with data "second" and put it on the status bar.

The two notifications have different values to be dismissed.

I would like that now, opening the menu containing notifications, if I click the first notification "show" is launched and shows to the user "first", then the notification is dismissed. If I click on the second notification "show" should be launched, display "second", and also this notification should be dismissed.

Instead what I get is that, independently of which of the two notifications I click, "show" il launched and displays "first", after that it dismiss the notification I clicked. If now I click the remaining notification "show is launched, displays again "first" and does't dismiss the notification (I must click clear notifications)

I think the problem is to prepare the PendingIntent with some flag, but I don't know which.
I build the PendingIntent in this way:

PendingIntent myPendingIntent = PendingIntent.getActivity(context, int, myIntent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

where context is the context ( :P )
int is 4 (a random value)
myIntent is the Intent to be used to launch the Activity (it has the FLAG_ACTIVITY_NEW_TASK)

should I use some other flags?

thanks!
sgom
Freshman
Freshman
 
Posts: 2
Joined: Wed Oct 29, 2008 7:01 pm

Top

Postby alpesh_harsoda » Tue Dec 16, 2008 11:08 am

hi sgom,
i have also one question that how can i get the number of pending event in status bar of android?because in my application when all pending events clear from status bar then my condition is true.so for that what i have to do for getting the number of pending event?
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby MrSnowflake » Tue Dec 16, 2008 1:05 pm

For different notifications, you should add the notification id to the intent, so you can getExtras().getInt("notifId") and dismiss that one.

On the other problem: you do not load the correct data I guess.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests