Prevent push notification from showing when app is in the foreground or running

Hello,

I have push notifications working good within my app, however, I still get them when my app is open and in the foreground. I want to prevent this from happening. It is causing an issue by creating multiple copies of my activity. I found some code online but doesn’t look to be applicable.

Check this doc https://github.com/Backendless/Android-SDK/blob/master/docs/push.md for your case you should override method onMessage and return false to prevent showing any message. For example

@Override
  public boolean onMessage( Context context, Intent intent )
  {
    do what you need
    return false;
  }

But how will it know to create a notification when the app is in the background? It will always return false? No?

You can return true when the app is in background and false otherwise. For detecting whether the app is in background, try searching similar questions since this is out of scope of Backendless support.