筆記一下開外部app的寫法
private void startOthersApp(String packagename) {
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage(packagename);
if (i == null)
throw new PackageManager.NameNotFoundException();
else {
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
} catch (PackageManager.NameNotFoundException e) {
}
}
沒有留言:
張貼留言