如何检查是否安装了Flash?

编程入门 行业动态 更新时间:2024-10-26 16:33:58
本文介绍了如何检查是否安装了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?

本文发布于:2023-07-17 06:37:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1130466.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:安装了   Flash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!