use*_*xxx 1 variables android android-activity
我想开始一个传递了变量的新活动.
代码到目前为止:
if(mostLikelyThingHeard.toUpperCase().equals("PLAY ONE"))
{
startActivity(new Intent("com.shaz.new"));
//I want to send an int value `1` to the new activity.
}
Run Code Online (Sandbox Code Playgroud)
可以这样做吗?
使用 putExtra(key, value)
这样做
if(mostLikelyThingHeard.toUpperCase().equals("PLAY ONE"))
{
Intent i=new Intent("com.shaz.new");
i.putExtra("key","value")
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
检索:
int value =getIntent().getIntExtra("key", 0); 0是默认值
| 归档时间: |
|
| 查看次数: |
3120 次 |
| 最近记录: |