问题描述
我正在创建 4 个应用程序(App1、App2、App3 和主应用程序).我在主应用中包含 app1、app2 和 app3.
I'm creating 4 apps (App1, App2, App3 and main app). I include app1, app2, and app3 in my main app.
我将在主应用中显示 3 个图标.当我点击第一个图标时,app1 打开,当我点击第二个图标时,app2 打开,当我点击第三个图标时,app3 打开.
I'll display 3 icons in my main app. When I click the first icon, app1 opens, when I click the second icon, app 2 opens, when I click the third icon, app 3 opens.
我怎样才能做到这一点?
How can I achieve this?
推荐答案
Android 仅支持每个 APK 1 个应用.但是,您可以通过对活动使用一点明显的魔法"来完成您想要做的事情.
Android only supports 1 app for each APK. However, what you are trying to do can be done through using a little manifest "magic" with activities.
通常每个应用都会有一个指定了 CATEGORY_LAUNCHER ("android.intent.category.LAUNCHER") 的 Activity.这会通知 Android 显示一个图标以启动应用程序.
Usually each app will have a single activity with CATEGORY_LAUNCHER ("android.intent.category.LAUNCHER") specified. This informs Android to display an icon to launch the app.
如果需要,您可以应用多个启动器过滤器的活动,然后使用该活动属性指定不同的图标.
If you case, you can have several activities with the launcher filter applied, and then specify different icons using that activity attribute.
您需要编写代码来处理每个图标/活动.如果它们目前是独立的应用程序,则需要将它们转换为库并导入到您的主"应用程序中.这样做有一些限制,但通常只需要您将每个库的主要"活动与您创建的相应新活动一起使用.
You will need to write the code to handle each icon/activity. If they are currently separate apps, then they need to be turned into libraries and imported into your "main" app. There are some limitations to doing this, but usually it will just require that you use each library's "main" activity with the corresponding new one that you created.
希望有帮助!
这篇关于是否可以在我的 android 应用中显示多个应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!