/**
* 检查已安装的应用程序。并打开
*/
private void openApp(){
//应用过滤条件
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager mPackageManager = mContext.getPackageManager();
List<ResolveInfo> mAllApps = mPackageManager.queryIntentActivities(mainIntent, 0);
//按包名排序
Collections.sort(mAllApps, new ResolveInfo.DisplayNameComparator(mPackageManager));
//遍历
for(ResolveInfo res : mAllApps){
//该应用的包名和主Activity
String pkg = res.activityInfo.packageName;
String cls = res.activityInfo.name;
// 打开酷狗音乐APP
if(pkg.contains("com.kugou.android")){
ComponentName componet = new ComponentName(pkg, cls);
Intent intent = new Intent();
intent.setComponent(componet);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
}
}