-1

I'm creating 4 apps (App1, App2, App3 and main app). I include app1, app2, and app3 in my main app.

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?

Nissim R
  • 542
  • 11
  • 29
Ana
  • 174
  • 1
  • 2
  • 10
  • 1
    Yes, it is possible. Think about how certain apps offer the ability to open Gmail or another existing app to send data. [Here](https://developer.android.com/training/basics/intents/index.html) is a link to aid you with Android Intents. – arkdevelopment Dec 28 '17 at 05:04
  • Ya. I know how to add google map to my app but i work only this way. if I click icon 1 it checks whether app 1 is on that phone. it will open directly otherwise it goes to play store. I'm having two query 1) how to click icon1 to open app1. no need to chk whether it is in phone or else play store. 1) How to add app1, app2 and app 3 code include in my main app code (IN Android studio) – Ana Dec 28 '17 at 05:16
  • Please provide code that you have already tried and/or are having problems with. – arkdevelopment Dec 28 '17 at 05:17
  • @arkdevelopment , MY doubt is how to include app1 code to my main project. – Ana Dec 28 '17 at 05:19

3 Answers3

0

Simple answer, yes.

I think the easiest way would be to import and deal with each app as if it were a library (https://developer.android.com/studio/projects/android-library.html), and in the main app you could put a startActivity(..) to the app you want.

0

Yes.

You will need the package name of your other three apps (eg com.example.app) and start them like this:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.app");
if (launchIntent != null) { 
    startActivity(launchIntent);
}
else {
    // app with given package not installed not installed
}

Code partly taken from this answer

jemand771
  • 457
  • 1
  • 6
  • 17
  • ya ,this code used to call three app but that three app already installed in that phone means this functionality work. Im haven't 3 apps in my phone. how can i call 3 apps? . My studio having main app. im convert 3 apps as aar file and add this as library.now how can i call this? – Ana Dec 29 '17 at 09:32
0

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.

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.

Hope that helps!

Jim
  • 10,172
  • 1
  • 27
  • 36