23Feb/1110
How to launch another app from your app
If you ever need to launch another app from your own it's actually easier than you think.
The PackageManager class provides some handy methods that make this a snap.
All you need to know is the package name of the app you want to launch and then use the code below:
protected void launchApp(String packageName) {
Intent mIntent = getPackageManager().getLaunchIntentForPackage(
packageName);
if (mIntent != null) {
try {
startActivity(mIntent);
} catch (ActivityNotFoundException err) {
Toast t = Toast.makeText(getApplicationContext(),
R.string.app_not_found, Toast.LENGTH_SHORT);
t.show();
}
}
}
You can use http://www.cyrket.com/ to get the package name of individual apps by looking at the url in the browser.
If you need to automate you can get a list of installed apps like this:
final PackageManager pm = getPackageManager(); Listpackages = pm .getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : packages) { Log.d(TAG, "Installed package :" + packageInfo.packageName); Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)); }
Hope this helps!

April 22nd, 2011 - 17:25
In your second example (for the app list), do you really have to use the tag?
Dympy
April 26th, 2011 - 11:50
Hi Dympy,
The tag is just used with Debug.log it just prints a trace output to the Logcat.
The tag parameter can be any string you want, it merely serves to help you categorize your traces.
You can get more info about it here: http://developer.android.com/reference/android/util/Log.html
Hope that helps!
April 29th, 2011 - 12:14
I didn’t mean that tag, I meant the tag.
You don’t really need it.
Dympy
September 18th, 2011 - 11:50
Hi! I’m new to android so I have a question that is kind of related to your post. I have a list of all the installed apps on my phone. I used your code so as to when click on one item in the list it launches the application. My problem is that it works for some of the apps in the list ( I mean that it launches them)…but for some it tells me that the application has stopped unexpectedly and it is forced to close and it doesn’t launch it. Some of the apps that don’t work are Calculator, Contacts, Dialer, Example Wallpapers and some of the apps that work are Browser, Search, Music, Custom Locale a.s.o. I don’t know what the problem might be and maybe you have already encountered this problem and can enlighten me, I would be grateful!
December 21st, 2011 - 04:25
I used the same technique, but it throws exception for Map and Camera application.
I’ve posted my question in detail here: http://stackoverflow.com/questions/8586299/camera-and-map-crashes-when-launched-from-my-custom-home-screen/8586324
will be glad if you can help. thanks in advance.
January 1st, 2012 - 00:58
@Lacra & Pranay
look under your manifest.xml
u need to give android permission to use those features
ex.
there are a lot of others but i thought this would be of help
January 1st, 2012 - 01:00
uses-permission android:name=”android.permission.CALL_PHONE”
uses-permission android:name=”android.permission.GET_TASKS”
uses-permission android:name=”android.permission.READ_CONTACTS”
uses-permission android:name=”android.permission.SET_WALLPAPER”
uses-permission android:name=”android.permission.INTERNET”
uses-permission android:name=”android.permission.EXPAND_STATUS_BAR”
January 17th, 2012 - 08:13
In the first code, nothing happens when i run it?
March 2nd, 2012 - 20:36
Hi all, my prob: I have a group of apps, when I launch each app in it, a message will appear and show the list of all of the other apps. I can click any app in this list and install it (if it isn’t installed) or launch it(if it is installed). I’m new to android, so, you can give me some advices?
February 5th, 2013 - 04:22
Thanks a lot. It is really helpful.