我正在使用 Intent
调用 Activity
,并且我需要在初始化时将变量传递给该 Activity
。在 iOS 上,您可以使用 initWithNibName
方法进行自定义初始化。如何在 Android 上实现类似的事情?
这是我创建Intent
的代码...
Intent myIntent = new Intent(webPush.this, webPushActivity.class);
startActivity(myIntent);
最佳答案
Intent myIntent = new Intent(webPush.this, webPushActivity.class);
myIntent.putExtra("mystring",strValue)' <<---put String here
startActivity(myIntent);
在第二个 Activity 中...
String str = getIntent.getExtras().getString("mystring");<<get string in second class
并检查这个
How do I pass data between Activities in Android application?
关于java - 将额外数据从 Activity 传递到 Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10602335/