Application with 2 launcher activities

纵然是瞬间 提交于 2019-12-03 15:28:00
FoamyGuy

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).

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!