具有 2 个启动器活动的应用程序

发布于 2024-12-26 18:57:51 字数 563 浏览 3 评论 0原文

包含两个活动

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

我有一个应用程序,清单中 。我这样做是为了在应用程序抽屉中有 2 个单独的条目。对于应用程序抽屉来说,它可以正常运行。

我的问题是在安装过程中出现的。安装仅具有一个主/启动器活动的应用程序后,最后一页有一个打开按钮,可启动刚刚安装的应用程序。在我的应用程序中,此打开按钮呈灰色。我认为这是因为它不知道如果按下打开按钮,我希望它启动两个活动中的哪一个。我可以在清单(或其他地方)中设置任何内容来指定我希望在安装过程结束时启动打开按钮的活动吗?我想一定有一些我可以设置的东西,因为当我通过 adb 使用 eclipse 安装应用程序时,它会启动这两个活动之一,幸运的是,它实际上是我希望它启动的活动。

I have an application that contains two Activities with

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

in the manifest. I did this so that there are 2 separate entries in the app drawer. It functions properly with regards to the app drawer as it is.

My question comes during the install. After you install an app with only one MAIN/LAUNCHER activity the last page has an open button that will launch the app that was just installed. With my app this open button is greyed out. I assume it is because it doesn't know which of the two activities I would want it to launch if the open button were pressed. Is there anything I can set in the manifest(or elsewhere) to specify which activity I'd like the open button to launch at the end of the install process? I am thinking there must be something I can set, because when I install the app through adb with eclipse it launches one of the two activities and luckily it is actually the one that I would like it to launch.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鼻尖触碰 2025-01-02 18:57:51

这个问题:

下载带有两个启动器的应用程序后来自市场的组件,单击“打开”将导致崩溃

帮助我让它按照我想要的方式工作。关键是添加:

    <activity-alias android:name="com.android.internal.app.ResolverActivity"
            android:targetActivity=".Main" android:exported="true">
    </activity-alias>

到清单并更改“.Main”以引用您希望在安装结束时使用打开按钮启动的活动。

请注意,必须在您引用的活动标记(在 xml 中)之后声明 Activity-alias 标记。

This question:

After downloading an application with two Launcher components from the Marketplace, clicking "Open" will cause a crash

Helped me to get it working how I wanted. The key was adding:

    <activity-alias android:name="com.android.internal.app.ResolverActivity"
            android:targetActivity=".Main" android:exported="true">
    </activity-alias>

to the manifest and changing ".Main" to reference the activity that you wish to start with the open button at the end of install.

Note that the activity-alias tag must be declared after the activity tag you are referring to (in the xml).

绅刃 2025-01-02 18:57:51

Android 文档强烈建议,如果您要从主屏幕启动多个 Activity,则每个 Activity 都应在其自己的任务中启动。请参阅本文了解更多信息。

这样做时,每个任务都会有一个单独的 taskAffinity 值。我相信设置为与应用程序包相同亲和力的任务将被安装程序选择为要启动的任务。

It is strongly recommended by the Android docs that if you are going to have multiple Activities launch from the Home screen, that each one be launched within its own task. Take a look at this article for more information.

When doing so, each task will have a separate taskAffinity value. I believe that the task which is set to the same affinity as the application's package is the one that will be picked up by the installer as the one to launch.

我偏爱纯白色 2025-01-02 18:57:51

我建议您进行 1 个活动来读取首选项并决定继续当前活动或打开另一个活动。

如果您不想开始新的活动,请尝试膨胀适当的片段。

I would suggest you to have 1 activity which reads preferences and decide to proceed with the current activity or to open another activity.

If you do not wish to start a new activity, try inflating appropriate fragment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文