[android-developers] PendingIntent always creates new Activity instance?
My app consists of an Activity and a service that runs in the
background. The service periodically checks a website for an alarm
condition. When the service detects the alarm, it should put a user
notification into the status bar. If the user clicks the notification,
it should display the app's activity. If the activity is already
running, that activity should become visible. If the activity is not
currently running, it should be created.
However the notification created by my service *always* creates a new
instance of the activity, whether the activity is currently running or
not. How do I get the desirable behavior?
Here is my service pseudo-code:
Notification notification = new
Notification(R.drawable.notification_icon, "Alert!",
System.currentTimeMillis());
Intent activityIntent = new Intent(MyService.this, MyActivity.class);
PendingIntent pendingIntent =
PendingIntent.getActivity(MyService.this, 0,
activityIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(MyService.this, "Alert condition
detected", pendingIntent);
_notificationManager.notify(MY_NOTIFICATION_ID, notification);
Thanks very much for your help!
Tom
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home