1

I have a fragmentActivity with many fragments. My activity (show just one fragment in first) launches an alarm with a pending intent like this :

    AlarmManager am = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);

       Intent intent = new Intent(context,MainFragmentActivity.class);
        intent.putExtra(MainFragmentActivity.IS_LOCKSCREEN, true);

        PendingIntent pendingintent = PendingIntent.getActivity(context,ALARM_ID, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        am.cancel(pendingintent);
        date = wakUp.getTime();
        am.set(AlarmManager.RTC_WAKEUP, wakUp.getTimeInMillis(),
                pendingintent);

And I finish the activity before the alarm rings.

My alarm rings, my activty is launched and shows a specific fragment (background red) because the extra MainFragmentActivity.IS_LOCKSCREEN is true .

I finish the activity and I run the application with recent app, the extra is always set to true, so the red fragment is launched. I don't understand, my extra should be set to false.

Thank you !

Pierre GM
  • 19,809
  • 3
  • 56
  • 67
vokvince
  • 61
  • 1
  • 5

1 Answers1

0

I'm not sure on why do You think the extra should become false, but if You haven't changed it inside Your activity (e.g. put false by yourself to the intent) recent app launch will provide it again and again. Probably, You might want to:
1) Clear flag in intent inside Your activity (then launch from recent should retain changed intent);
OR
2) Use FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS with the intent in order to eliminate that activity from recent apps (checkout discussion here for more about that launch flag use with e.g. notification);

Community
  • 1
  • 1
sandrstar
  • 12,503
  • 8
  • 58
  • 65