Android 判断应用是否安装

    /**
     * 支付宝 "com.eg.android.AlipayGphone", "com.eg.android.AlipayGphone.AlipayLogin"
     * 微信   "com.tencent.mm","com.tencent.mm.ui.LauncherUI"
     * QQ     "com.tencent.mobileqq","com.tencent.mobileqq.activity.SplashActivity"
     * 微博   "com.sina.weibo","com.sina.weibo.SplashActivity"
     * 淘宝   "com.taobao.taobao","com.taobao.tao.welcome.Welcome"
     * @param context
     * @param pkg
     * @param cls
     * @return
     */
    public static boolean checkAppInstalled(Context context, String pkg, String cls){
        PackageManager pm = context.getPackageManager();
        Intent intent = new Intent();
        ComponentName cmp = new ComponentName(pkg, cls);
        intent.setComponent(cmp);
        List<ResolveInfo> rf = pm.queryIntentActivities(intent,PackageManager.MATCH_ALL);
        return rf.size() > 0;
    }

你可能感兴趣的:(Android)