private void startApk(String mstrPakageID) {
// 获取当前应用程序的第一个activity.
try {
PackageInfo packinfo = getPackageManager().getPackageInfo(
mstrPakageID, PackageManager.GET_ACTIVITIES);
ActivityInfo[] infos = packinfo.activities;
if (infos != null && infos.length > 0) {
ActivityInfo activityinfo = infos[0];
String classname = activityinfo.name;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName(mstrPakageID, classname);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intent);
} else {
Toast.makeText(this, "无法开启当前应用", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// e.printStackTrace();
Toast.makeText(this, "无法开启当前应用", Toast.LENGTH_SHORT).show();
}
}