jagrakye jagrakye - 1 year ago 84
Android Question

Is there a way for a notification to know the application is already open? Or specifically which activity is open?

I've got an activity that only opens via a notification. That notification can pop up while in the activity as well. Is there a way to tell the notification the activity is already open so I can change its behavior accordingly?

Answer Source

There is no way for the notification to know, it just has a PendingIntent that is fired when it's clicked. But you can be smart about handling the intent.

For your case I think you should look at Activity launch modes. Specifically I think adding launchMode="singleTop" to your <activity> tag in AndroidManifest.xml does exactly what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download