1、//跳转至另一个应用的主入口Activity(根据包名自动识别主入口) Intent intent = context.getPackageManager().getLaunchIntentForPackage("程序包名"); context.startActivity(intent);
2、指定主Activity跳转
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
//参数是包名,注意直接用类名不行
ComponentName cn=new ComponentName("包名",
"全路径Activity");
intent.setComponent(cn);
startActivity(intent);
3、跳转非主Activity
注:非主入口Activity的情况下,被跳转的Activity需要在manifest里声明exported属性为true,表示此activity对外公开,才能直接跳转。
Intent intent=new Intent();
//参数是包名,类全限定名,注意直接用类名不行
ComponentName cn=new ComponentName("包名",
"全路径Activity");
intent.setComponent(cn);
startActivity(intent);