Android: Starting app from 'recent applications' starts it with the last set of extras used in an intent

后端 未结 3 1317
刺人心
刺人心 2020-12-06 05:27

Bit of a confusing problem for me here:

I\'ve got a home screen widget which, when clicked, starts my main app Activity with a few extras put in the intent:

3条回答
  •  一个人的身影
    2020-12-06 06:14

    You should clear the extras from your intent after using them.

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        return;
    }
    String value1 = extras.getString("Value1");
    String value2 = extras.getString("Value2");
    extras.clear();
    

提交回复
热议问题