主要活动发射器和清单主要区别

时间:2016-11-03 12:33:07

标签: android launcher

任何人都可以准确地解释

之间的区别
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />

为什么当我们移除上述任何一个时,我的应用程序无法运行,或者我们无法运行我们的应用程序。

4 个答案:

答案 0 :(得分:1)

它们不是不同的代码,它们构成了同一个标记的一部分,称为 <!-- Set custom default icon. This is used when no icon is set for incoming notification messages.See README(https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-icon) for more. --> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" /> <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. See README (https://github.com/firebase/quickstart-android/tree/master/messaging#custom-default-color) for more. --> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent" /> 。您可以将此部分代码放在您希望应用程序启动的任何其他活动中。

答案 1 :(得分:1)

MAIN 操作意味着可以用作应用程序的顶级入口点的所有活动。它不需要Intent中的任何其他信息,即它不接收任何输入数据启动。

LAUNCHER 类别表示应在应用程序启动器中列出入口点。

就像我们只能使用其中一个的例子一样

主要操作和启动器可以有多个活动。但是如果我们在Launcher类别中定义了多个活动,那么我们必须使用属性android:taskAffinity =&#34;&#34;,它指定了要启动的确切包和活动。

答案 2 :(得分:1)

android.intent.action.MAIN匹配可用作应用程序顶级入口点的所有活动。

LAUNCHER类别表示此入口点应列在应用程序启动器中。

当未明确指定其组件名称时,Context.startActivity()方法需要使用默认类别来解析您的活动。

所以类别LAUNCHER +操作主要让此活动的图标显示在可用“应用程序”的启动器列表中。

您可以在AndroidManifest.xml中的多个Activity上使用此intent-filter,所有这些都将显示在“应用程序”列表中。

意图记录为here和IntentFilters here

答案 3 :(得分:0)

android.intent.action.MAIN 匹配可用作应用程序顶级入口点的所有活动。

LAUNCHER 类别表示此入口点应列在应用程序启动器中。

默认类别是Context.startActivity()方法在未明确指定其组件名称时解析活动所必需的。

所以类别LAUNCHER + action MAIN让此活动的图标显示在可用“应用程序”的启动器列表中。

您可以在intent-filter中的多个活动中使用此AndroidManifest.xml,并且所有这些活动都会显示在“应用程序”列表中。

意图记录为here和IntentFilters here

相关问题