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.
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. What’s the best way to package the “com.A.myapp” to my existing app?
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. Soapp1would be in packagecom.A.myapp.myapp1. The second app “myapp2” would be in packagecom.A.myapp.myapp2.In the
Packagesection of the project’s manifest file, put “com.A.myapp” as the root. Register all activities in the manifest file of your entire project. Thenapp1can invoke the activity inapp2with a call like this:NOTE: This will officially make this one entire app as Android is concerned. 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