1. ? ? ?
?Intent intent = getPackageManager().getLaunchIntentForPackage("com.xxx.yyyy");
? ? ? ? if(intent!=null){
? ? ? ? ? ?startActivity(intent);
? ? ? ?}else{
? ? ? ? ? Toast.makeText(this,"didnt find com.sogou.baby",Toast.LENGTH_SHORT).show();
? ? ? ?}
2.
try{
Intent intent =newIntent();
ComponentName componentName =newComponentName("com.xxx.yyy","com.xxx.yyy.activities.LoginActivity");
intent.setComponent(componentName);
startActivity(intent);
}catch(Exception e) {
Toast.makeText(this,"didnt find com.sogou.baby",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
注意:LoginActivity需要配置為android :exported = true箱蝠;否則打不開(kāi)