从一个app中打开另外一个app

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;否则打不开

你可能感兴趣的:(从一个app中打开另外一个app)