判断手机是否装了微信public static boolean isWeixinAvilible(Context context) { final PackageManager packageManager = context.getPackageManager();// 获取packagemanager List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息 if (pinfo != null) { for (int i = 0; i < pinfo.size(); i ) { String pn = pinfo.get(i).packageName; if (pn.equals("com.tencent.mm")) { return true; } } } return false; },下面我们就来聊聊关于手机要不要装微信?接下来我们就一起去了解一下吧!

手机要不要装微信(判断手机是否装了微信)

手机要不要装微信

判断手机是否装了微信

public static boolean isWeixinAvilible(Context context) { final PackageManager packageManager = context.getPackageManager();// 获取packagemanager List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息 if (pinfo != null) { for (int i = 0; i < pinfo.size(); i ) { String pn = pinfo.get(i).packageName; if (pn.equals("com.tencent.mm")) { return true; } } } return false; }

2.加入代码

Intent intent = new Intent(); ComponentName cmp=newComponentName("com.tencent.mm","com.tencent.mm.ui.LauncherUI"); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(cmp); startActivity(intent);

,