布尔变量未传递给getBoolean变量

时间:2012-05-11 20:41:18

标签: android bundle

Intent i = new Intent(AndroidGUIActivity.this, Basic_database_questionsActivity.class);
Bundle b = new Bundle();
// get the current value of timerStart variable and store it in timerlogic
Log.e(LOGS, "Whatis the value of timerstart inside the intentcalls method" +  timerStart);
b.getBoolean("timerlogic", timerStart);
boolean timermagic= b.getBoolean("timerlogic");
Log.e(LOGS, "Whatis the value of timerstart passed to timermagic" + timermagic);

我不确定为什么timermagics变量的值为false而不是true

1 个答案:

答案 0 :(得分:3)

使用Bundle#putBoolean(String,boolean)设置布尔值,所以:

b.getBoolean("timerlogic", timerStart);

应该是:

b.putBoolean("timerlogic", timerStart);