is Tencent QQ App Existed - Android App

Android examples for App:Popular App

Description

is Tencent QQ App Existed

Demo Code


//package com.java2s;
import java.util.List;
import android.content.Context;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {

    public static final String PACKAGE_NAME_TENCENT_QQ = "com.tencent.mobileqq";

    public static boolean isTencentQQExisted(Context context) {
        if (checkApp(context, PACKAGE_NAME_TENCENT_QQ)) {
            return true;
        } else {/*from   w  ww .  j  a va  2s  .  c  o  m*/
            return false;
        }
    }

    private static boolean checkApp(Context context, String packageName) {
        PackageManager pm = context.getPackageManager();
        List<PackageInfo> packs = pm.getInstalledPackages(0);
        for (PackageInfo pi : packs) {
            if (pi.applicationInfo.packageName.equals(packageName)) {
                return true;
            }
        }
        return false;
    }
}

Related Tutorials