简体   繁体   English

启动器活动的默认意图

[英]Default Intent for launcher Activity

What is value of Intent of launcher activity 启动器活动的意图的价值是什么

hello friends, I'm new to android. 朋友你好,我是android新手。 I'm working on android activity and Intent . 我正在研究android activityIntent 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: 在第二个活动中,我使用getIntent()方法获取OnCreate方法中调用意图的引用,如下所示:

Intent in = getIntent();
if(in != null) //do something..

In second activity getIntent() method return the reference of calling intent . 在第二个活动中, getIntent()方法返回调用intent的引用。 But when I Use getIntent() method in onCreate method of launcher activity, its value was not null. 但是,当我在启动器活动的onCreate方法中使用getIntent()方法时,其值不为 null。 So what reference is passed to intent when we use getIntent() method in launcher activity 因此,当我们在启动器活动中使用getIntent()方法时,传递给意图的引用是什么

那么,当您单击app_icon时,Android OS会启动活动,它会浏览清单文件并找到启动器活动,然后启动它

Get the intent which has started your activity using the getIntent() method: 使用getIntent()方法获取已开始活动的意图:

Intent intent = getIntent();

Your data is represented as strings, then you can use intent.getStringExtra(String name) method. 您的数据表示为字符串,然后可以使用intent.getStringExtra(String name)方法。 In your case: 在您的情况下:

String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM