Android判读是否安装了某一款APP

    /**
    * @Title: isAvilible 
    * @Description: 断手机已安装某程序
    * @param @param context
    * @param @param packageName
    * @param @return    
    * @return boolean    
    * @throws
     */
    public static boolean isAviliblePackage(Context context, String packageName){ 
        final PackageManager packageManager = context.getPackageManager();//获取packagemanager 
        List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);//获取所有已安装程序的包信息 
        List<String> pName = new ArrayList<String>();//用于存储所有已安装程序的包名 
       //从pinfo中将包名字逐一取出,压入pName list中 
        if(pinfo != null){ 
            for(int i = 0; i < pinfo.size(); i++){ 
                String pn = pinfo.get(i).packageName; 
                pName.add(pn); 
            } 
        } 
        return pName.contains(packageName);//判断pName中是否有目标程序的包名,有TRUE,没有FALSE 
  } 

 

posted @ 2015-04-27 17:06  yshy  阅读(350)  评论(0编辑  收藏  举报