在mainfest xml文件多android.intent.action.MAIN文件、xml、mainfest、android

2023-09-05 08:54:47 作者:南乔枝

我是新的Andr​​oid开发我看过很多教程,他们只有 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应用程序的演示,我已经看到多个 android.intent.action.MAIN 语句中的 mainfest.xml 的。任何人都可以解释为什么 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?

和,在这种情况下,我们应该有多个 S在manifest.xml的?

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>

事实证明,我的启动屏幕现在有两种不同的图标相同的程序,每一个不同的活动。这是有道理的,因为主/ 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.