捆绑未清除

Bundle not cleared

我有一个奇怪的问题。如何在调用其方法后无法清除 Bundle clear() 这是我的代码:

if(isFromPushNotif) {
                        Bundle pushNotifBundle = getIntent().getExtras() ;
                        Log.i("SplashScreen"," before clear "+pushNotifBundle);
                        intent.putExtras(pushNotifBundle) ;
                        getIntent().getExtras().clear();
                        Log.i("SplashScreen"," after clear "+getIntent().getExtras()); //Here bundle is not cleared , log displays all the initial elements

                    }

startActivity(intent);
overridePendingTransition(0, 0);
finish();

关于此处接受的答案 Android. Can't clear or replace extras

This problem was solved by using onNewIntent instead of using onCrete in Activity.

试试这个

  • 清除你的bundle

     getIntent().removeExtra("your_key_here_to_be_removed");