1,知道要启动的包名以及要启动的Activity:
Intent intent = new Intent();
/**下面方法的参数分别是指要启动应用的包名及对应的Activity*/
ComponentName cpn= new ComponentName("com.ldm.demo","com.ldm.demo.TextActivity");
intent .setComponent(cpn);
startActivity(intent );
2,只知道应用的包名:
PackageManager packageManager = getPackageManager();
Intent intent=new Intent();
intent =packageManager.getLaunchIntentForPackage("packageName");/**packageName指的就要启动应用的包名*/
if(intent==null){
System.out.println("APP not found!");
}
startActivity(intent);
}
}
3,知道要启动的包名以及要启动的Activity应用启动并传递数据: