2

Possible Duplicate:
Android: How can I get the current foreground activity (from a service)?
Optionally starting activities and using notifications from services in Android. Only launch or notify if a certain app is present

If I produce a notification when I get an update in my SyncService, how do I prevent it from appearing if I am already in the activity that uses the new information?

It's kind of like when you use the gmail app, a notification will come when you are outside of the app, but you never see it when you are in it.

Community
  • 1
  • 1
Hank
  • 3,367
  • 10
  • 48
  • 86

1 Answers1

0

CommonsWare provides a solution to this as an answer to this question.

Specifically, he links to this blog post, which explains the use of ordered broadcasts.

As a not-so-efficient idea, you could implement a broadcast receiver in your activity and service, then before sending the notification, send a broadcast intent to your activity and wait for a response. If you don't get a response, raise the notification.

Community
  • 1
  • 1
John Leehey
  • 22,052
  • 8
  • 61
  • 88