2
//這是我的主要活動如何清除從其他活動得到的bunle值......?
@Override
protected void onResume() {
super.onResume();
System.out.println("onResume()");
// getting the value form some other class(checking one the activity is started)
try {
bundle = getIntent().getExtras();
myFlag = bundle.getBoolean("KEY");
} catch (Exception e) {
System.out.println(".......Error.......");
}
}
我提出的myFlag =真,我的問題是,當我不斷改變方向(即重新啓動的活動),我想myFlag =假,但它仍然是正確的...意味着一旦方向改變,我想清除束值。 我嘗試過在onDestroy()方法中使用bundle.clear()和bundle.remove(「KEY」),但不工作。
我已經使用這個..
@Override
protected void onDestroy() {
super.onDestroy();
System.out.println("onDestroy()");
if(bundle!=null) {
bundle.clear();
// i also use the below statement
// bundle.remove("KEY");
}
}
閱讀本文件:[處理運行時更改] (http://developer.android.com/guide/topics/resources/runtime-changes.html),你會得到線索。 –