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!
Pingback: Tims Blog » Blog Archive » Links and riding
Pingback: How to: How to get a list of installed android applications and pick one to run | SevenNet
Pingback: How-to: How to get a list of installed android applications and pick one to run #development #programming #answer | Good Answer