android - 我是否必须在 list 文件中声明每个 Activity ?

标签 android android-activity android-manifest

我想创建一个 Activity 但不必在 list 文件中声明它。这可能吗?在我看到的所有地方,似乎每个 Activity 都必须在 list 中声明,但我注意到一些 Activity ,例如内置的 ChooserActivity,并没有在我的 list 文件中声明。

最佳答案

简短回答:是的,应用程序中的每个 Activity 都必须在 list 中声明。如 Android 文档中所述, list 的目的(除其他事项外)是:

It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.)

http://developer.android.com/guide/topics/manifest/manifest-intro.html#ifs

因此,您的应用程序中的任何 Activity 类必须在您的 list 中定义。 Intent 、服务等也是如此,即使这些组件无法从您的应用程序外部访问。

至于 ChooserActivity 和您没有在代码中定义的任何其他 Activity,它们将在另一个 Manifest 中有自己的定义。如果出于某种原因您决定在您的应用程序之外子类化一个现有的 Activity,那么您也必须在您的 Manifest 中定义它。

关于android - 我是否必须在 list 文件中声明每个 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20532674/

相关文章:

android - 为什么我添加 "android:id"时我的 android 应用程序崩溃?

java - 如何在不完成/停止子 Activity 的情况下完成子 Activity 的父 Activity ?

android - 如何在不扩展 Activity 的类中显示 Toast 消息

android - 将消息从一个 Activity 发送到另一个 Activity

android - 未找到 Launcher Activity ,启动只会同步设备上的应用程序包

android - 为什么我的应用程序显示为与三星设备上的谷歌游戏商店不兼容?

android - Cloud Firestore 数据库结构

java - Unity Daydream APK构建失败

Java 扩展 vs 对象引用?

android - 目标和最低 Android 版本支持平板电脑