0

After clicking a pushed notification and app is reopened (back click, which closes the app, and then re-opening app) then it gets the intent from getIntent() and does the things its supposed to do when coming from a notification.

If I push a notification and close app and reinstall the app (while working in debug mode with Eclipse) to run again it runs as if it was the first time, but if I close the app and then open it again it still has the intent from before (that came from the notification).

How do I clear the getIntent() after it's been used? And why is it, after closing the app, still 'active'?

Receiver

public class Receiver extends ParsePushBroadcastReceiver {

    @Override
    public void onPushOpen( Context context, Intent intent ) {
        Intent i = new Intent( context, Main.class );
        i.putExtras( intent.getExtras() );
        i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
        context.startActivity( i );
        ParseAnalytics.trackAppOpened( intent );
    }

}

Main Activity

@Override
protected void onCreate( Bundle savedInstanceState ) {
    super.onCreate( savedInstanceState );

    try {
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String jsonData = extras.getString( "com.parse.Data" );
        JSONObject jObj = new JSONObject( jsonData );

        Log.e(TAG, "Intent extras: " + jObj.get( "data" ).toString();

    } catch ( Exception e ) { /* Nom nom nom */ }

    .... other code
}
Jonas Borggren
  • 2,591
  • 1
  • 22
  • 40
  • Just to be clear, when you launch the app from a notification and then close the app (press BACK). then you restart the app and get the `Intent` from the notification - are you starting the app the second time from the list of recent tasks? or by clicking the app icon on the HOME screen? See my answer to this question, it may help: http://stackoverflow.com/a/19820057/769265 – David Wasser Nov 28 '14 at 17:40
  • By clicking on the home screen app icon. I will see your answer. – Jonas Borggren Dec 01 '14 at 08:15

0 Answers0