清单xml文件中有多个android.intent.action.MAIN [英] Multiple android.intent.action.MAIN in manifest xml file

查看:482
本文介绍了清单xml文件中有多个android.intent.action.MAIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android开发的新手,我看过很多教程,其中只有android.intent.action.MAIN,这基本上是应用程序的开始活动.

I am new to Android development I seen lots of tutorial where they have only android.intent.action.MAIN which is basically a start activity of the application.

但是,在android应用演示中,我在 mainfest.xml 中看到了多个android.intent.action.MAIN语句.谁能解释为什么mainfest.xml有多个android.intent.action.MAIN语句?

But, in the android app demos, I have seen multiple android.intent.action.MAIN statements in mainfest.xml. Can anyone explain why the mainfest.xml has multiple android.intent.action.MAIN statements?

而且,在哪种情况下,我们应该在manifest.xml中包含多个MAIN?

And, in which scenarios we are supposed to have multiple MAINs in manifest.xml?

推荐答案

它们是程序的不同入口点.例如,我刚刚创建了两个活动,两个活动都有典型的意图过滤器

They're different entry points into the program. For instance, I just created two activities, both of which had the typical intent filter

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

事实证明,我的启动器屏幕现在针对同一程序具有两个不同的图标,每个不同的活动都有一个图标.这是有道理的,因为MAIN/LAUNCHER意向过滤器实际上告诉android该活动是应用程序的启动活动. android的意图过滤器模型中没有任何内容会强制每个应用程序只有一个启动活动.

It turns out that my launcher screen now has two different icons for the same program, one for each different activity. This makes sense, since the MAIN/LAUNCHER intent filter essentially tells android that the activity is the app's starting activity. Nothing in android's intent filter model forces each app to have one and only one starting activity.

这篇关于清单xml文件中有多个android.intent.action.MAIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆