如何检查是否安装了Flash? [英] How to check if Flash is installed?

查看:140
本文介绍了如何检查是否安装了Flash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的这个片段,以检查是否安装了应用程序/活动:

i'm using this snippet to check if an app/activity is installed:

    public static boolean isIntentAvailable(Context context, String action) {
    final PackageManager packageManager = context.getPackageManager();
    final Intent intent = new Intent(action);
    List<ResolveInfo> list =
            packageManager.queryIntentActivities(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

public static boolean isScanAvailable(Context context) {
    return isIntentAvailable(context, "com.google.zxing.client.android.SCAN");
}

在上面的例子中它检查是否安装的C扫描仪应用的酒吧$ C $,它工作得很好。 不过,如果我尝试使用来检查的Adobe需要安装Flashplayer com.adobe.flashplayer 它不工作,并始终返回false。

In the above example it checks if the Barcode Scanner App is installed, which works just fine. However, if i try to check for the Adobe Flashplayer using com.adobe.flashplayer it doesn't work and always returns false.

有没有更好/更可靠的方法来检查闪光?

Is there a better / more reliable method to check for Flash?

推荐答案

嗯是的。我的code以上贴确实意图检查未工作的flash播放器(没有公开意图我猜的)。

Uhm yeah. My code posted above does Intent checking which isn't working for the flashplayer (no public intents i guess).

更明显的方式是只使用 getPackageInfo()这工作得很好:

The more obvious way would be to just use getPackageInfo() which works just fine:

    public static boolean isFlashAvailable(Context context) {
    String mVersion;
    try {
        mVersion = context.getPackageManager().getPackageInfo(
                "com.adobe.flashplayer", 0).versionName;
          Log.d("Flash", "Installed: " + mVersion);
          return true;
    } catch (NameNotFoundException e) {
          Log.d("Flash", "Not installed");
          return false;
    }
   }

(作为额外的奖励,我们得到确切的版本号也是如此)

(As an added bonus we get the exact version number too)

这篇关于如何检查是否安装了Flash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆