0

I am new in app development. My app contains notification features. If I received notification means notification page will be shown. if i press back button from my notification means it does not redirect to my app it will be closed. But I want to open my app if I click back button from notification. kindly provide any ideas. My code:

public void onMessageReceived(String from, Bundle data) {
   ....
   NotificationCompat.Builder notificationBuilder = new     NotificationCompat.Builder(this).setContentText(message).build();
    ...
}
Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106
Palani kumar
  • 119
  • 1
  • 10

1 Answers1

0

Not entirely clear what you would like to do. You mean your notification opens an activity, then you press the back button and you would like to go to the main activity of your app? In any case you would have to override the back button capabilities.

One method would be:

@Override
    public void onBackPressed() {
        // Write your code here

        super.onBackPressed();
    }

This could help you too:

Android - How To Override the "Back" button so it doesn't Finish() my Activity?

Notification opens activity, back button pressed, main activity is opened?

Community
  • 1
  • 1
SunnySonic
  • 1,318
  • 11
  • 37