How to pass intent with extras to an already running activity

后端 未结 2 1237
攒了一身酷
攒了一身酷 2020-12-30 22:12

I have a BroadcastReceiver which launches a HomeActivity with some information passed with the extras.

What happens when the activity is a

2条回答
  •  情书的邮戳
    2020-12-30 22:44

    Make sure when you are launching the intent from the BroadcastReceiver you set the FLAG_ACTIVITY_SINGLE_TOP flag.

    intent.addFlags (FLAG_ACTIVITY_SINGLE_TOP);
    
    ...
    
    
    class HomeActivity extends Activity {
       ...
       @Override
       protected void onNewIntent(Intent intent) {
          Bundle extras = intent.getExtras();
       }
       ...
    }
    

提交回复
热议问题