Android 常用代码
【1】判断APP 是否安装
public static boolean hasInstalled(String pkgname) { if (!TextUtils.isEmpty(pkgname)) { try { content.getPackageManager().getApplicationInfo(pkgname, 0); return true; } catch (Exception e) { e.printStackTrace(); return false; } } return false; }
【2】判断APP中是否存在某Activity
public static boolean hasActivity(Context context, Intent intent){ if(null == context || null == intent){ return false; } PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfoList == null || resolveInfoList.size() <= 0) { return false; } return true; }
版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论