To launch an application programmatically in Android given an ApplicationInfo
, do:
ApplicationInfo ai;
PackageManager pm = getPackageManager();
try {
Intent i = pm.getLaunchIntentForPackage(ai.packageName);
startActivity(i);
} catch (Exception e) {
Toast t = Toast.makeText(this, "Couldn't launch the application.", Toast.LENGTH_SHORT);
t.show();
}
Apparently this was harder pre-1.5, where you had to look for the proper activity yourself.
No comments:
Post a Comment