Search code examples
androidandroid-fragmentsnotificationsoncreate

reset action passed via notification once used in onCreate


I am able to set an action when a notification is created. Once user clicks on it, application is getting opened and I was able to check the action value. I referred below link

Android opening specific tab fragment on notification click

Using setAction() I am setting a action and on click on notification , in activity onCreate() I am able to get the value.

My problem is every time onCreate() is called I am getting the value when onCreate() is called (such as rotation). Is there a way to clear the action once I captured in onCreate(), I want getActivity().getAction() should give value only when the app is re invoked by clicking notification.


Solution

  • You can either use Activity.setIntent(new Intent()) to set a blank intent or use Activity.getIntent().setAction(null) to set a blank action after you received the action.