简体   繁体   English

从我的应用程序运行另一个 android 应用程序?

[英]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.

相关问题 从我的Android应用中打开另一个应用 - opening another app from my app in android 从另一个运行的Android应用程序中检索数据 - Retrieving Data from another running android app 如何从我的 android React Native 应用程序打开另一个应用程序? - How to open another app from my android React Native app? 如何从Android中另一个应用程序的共享菜单启动我的应用程序 - How to launch my app from share menu of another app in android 从另一个应用程序接收共享 URL 到我的 Android 应用程序无法正常工作 - Receiving a shared URL from another app into my Android app not working android:如何从我的应用程序打开另一个应用程序? - android: how do i open another app from my app? Eclipse没有运行我的Android应用程序 - Eclipse not running my android app 检查我的应用程序是否在Android中运行 - Check if my App is running in Android 如何从设备上运行的Android应用程序向另一个运行相同应用程序的设备发送推送通知? - how to send a push notification from an android app running on a device to another device running the same app? 如何将我的 android 应用程序连接到另一个应用程序? - How to connect my android app to another app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM