【发布时间】:2016-04-14 14:40:03
【问题描述】:
我试图通过一个意图将一个 int 传递给另一个类,并成功地传递了整数,但是我不确定如何将一个 Bundle 转换为一个整数。
意图代码:
private void nextPage()
{
Intent intent = new Intent(this, Timer.class).putExtra("totalTime", totalTime);
startActivity(intent);
}
Timer 类中的代码:
Bundle time = getIntent().getExtras();
if(time == null)
{
timeDisp.setText("Failed.");
}
else
{
totalTimeMs = Integer.parseInt(String.valueOf(time));
timeDisp.setText(totalTimeMs);
}
提前致谢:)
【问题讨论】:
标签: java android android-intent bundle