hello friends, I'm new to android. I'm working on android activity
and Intent
. As i did in my launcher activity
Intent in = new Intent(getApplicationContext(), SecondActivity.class);
startActivity(in);
and in second activity i use getIntent()
method to get an reference of calling intent in OnCreate
method as:
Intent in = getIntent();
if(in != null) //do something..
In second activity getIntent()
method return the reference of calling intent
. But when I Use getIntent()
method in onCreate
method of launcher activity, its value was not null. So what reference is passed to intent when we use getIntent()
method in launcher activity
那么,当您单击app_icon时,Android OS会启动活动,它会浏览清单文件并找到启动器活动,然后启动它
Get the intent which has started your activity using the getIntent() method:
Intent intent = getIntent();
Your data is represented as strings, then you can use intent.getStringExtra(String name) method. In your case:
String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.