A跳到B
//判断B程序是否存在
public static boolean isInstall(Context context, String packageName) {
if (packageName ==null ||"".equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager().getApplicationInfo(
packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
}catch (PackageManager.NameNotFoundException e) {
return false;
}
}
if (isInstall(MainActivity.this, "B程序包名")) {
1、Intent intent =new Intent();
intent.setClassName("B程序包名", "要跳到B程序的那个activity全包名");
Bundle bundle =new Bundle();
bundle.putString("zrl", id_et.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
2、 Intent intent = getPackageManager().getLaunchIntentForPackage("B程序包名");
startActivity(intent);
3、 Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName cn = new ComponentName("B程序包名", "要跳到B程序的那个activity全包名");
intent.setComponent(cn);
startActivity(intent);
}else {
Toast.makeText(MainActivity.this, "没有这个App", Toast.LENGTH_LONG).show();
}
网友评论