A应用中打开B应用

//拿到要开启的B应用的packageName(包名);

/ 访问手机安装的所有应用信息

PackageManager packageManager = context.getPackageManager();

List<PackageInfo> installedPackageInfos = packageManager.getInstalledPackages(0);

/ packageManager.getInstalledApplications(flags);

/ 拿到每个安装了的应用的相关信息

for (PackageInfo packageInfo : installedPackageInfos) {

String apkPackageName = packageInfo.packageName;// 应用包名

}

//拿到要启动的B应用的intent:(this 即A应用的this,packageName:B应用的包名)

Intent intent = this.getPackageManager().getLaunchIntentForPackage(packageName);

this.startActivity(intent);

你可能感兴趣的:(A应用中打开B应用)