【问题标题】:Bundle not cleared捆绑未清除
【发布时间】:2017-11-13 19:57:59
【问题描述】:

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

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();

【问题讨论】:

  • 发布捆绑包的值here

标签: android android-fragments android-bundle


【解决方案1】:

试试这个

  • 清除您的bundle

     getIntent().removeExtra("your_key_here_to_be_removed");
    

【讨论】:

    【解决方案2】:

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

    这个问题是通过在Activity中使用onNewIntent而不是使用onCrete解决的。

    【讨论】:

      猜你喜欢
      • 2011-12-15
      • 2018-08-03
      • 1970-01-01
      • 2015-12-03
      • 2013-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多