is Sina Weibo App Existed - Android App

Android examples for App:Popular App

Description

is Sina Weibo 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_SINA_WEIBO = "com.sina.weibo";

    public static boolean isSinaWeiboExisted(Context context) {
        if (checkApp(context, PACKAGE_NAME_SINA_WEIBO)) {
            return true;
        } else {/*  www.j  a v  a  2s  . co  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