[英]Running another android app from my app?
When I press a button I want to run another separate app I made, but I want to somehow package these two apps together so the user only needs to download one app.当我按下一个按钮时,我想运行我制作的另一个单独的应用程序,但我想以某种方式将这两个应用程序 package 放在一起,因此用户只需要下载一个应用程序。
I'm aware of starting an intent like this:我知道开始这样的意图:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.A.myapp","com.A.myapp.MainActivity"));
startActivity(intent);
But that assumes I've downloaded the app "com.A.myapp" separately.但这假设我已经单独下载了应用程序“com.A.myapp”。 What's the best way to package the "com.A.myapp" to my existing app? package 到我现有应用程序的“com.A.myapp”的最佳方法是什么?
The easiest way to do what you're trying to do would be to simply create a new project that contains both apps.做你想做的最简单的方法是简单地创建一个包含两个应用程序的新项目。 Since apps generally are started by an initial entry Activity
, you can keep them in separate packages like they are now as long as they have the same root name.由于应用程序通常由初始条目Activity
启动,因此只要它们具有相同的根名称,您就可以像现在一样将它们保存在单独的包中。 So app1
would be in package com.A.myapp.myapp1
.所以app1
将在 package com.A.myapp.myapp1
。 The second app "myapp2" would be in package com.A.myapp.myapp2
.第二个应用程序“myapp2”将位于 package com.A.myapp.myapp2
。
In the Package
section of the project's manifest file, put "com.A.myapp" as the root.在项目清单文件的Package
部分中,将“com.A.myapp”作为根。 Register all activities in the manifest file of your entire project.在整个项目的清单文件中注册所有活动。 Then app1
can invoke the activity in app2
with a call like this:然后app1
可以通过如下调用调用app2
中的活动:
Intent createIntent = new Intent();
createIntent.setClassName(this.getApplicationContext(), "com.A.myapp.myapp2.ActivityA");
startActivity(createIntent);
NOTE: This will officially make this one entire app as Android is concerned.注意:这将正式成为一个完整的应用程序,因为 Android 涉及。 If you want to keep them completely separate, you need to use intent filters and call the other app implicitly.如果你想让它们完全分开,你需要使用意图过滤器并隐式调用另一个应用程序。 You can start with this link for that.你可以从这个链接开始。
http://developer.android.com/guide/topics/intents/intents-filters.html http://developer.android.com/guide/topics/intents/intents-filters.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.