Android 检查应用是否安装、唤起的方法

检查指定包名应用是否安装

private boolean check(String packageName) {
    if (TextUtils.isEmpty(packageName)) return false;
    try {
        PackageInfo info = getContext().getPackageManager().getPackageInfo(packageName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        ApplicationInfo appInfo = getContext().getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        return info != null && appInfo != null;
    } catch (Exception e) {
        return false;
    }
}

通过指定包名唤起应用

private boolean launchApp(String packageName) {
    Intent intent = getPackageManager().getLaunchIntentForPackage(param);
    startActivity(intent);
 }

你可能感兴趣的:(Android)