检测Android上是否安装了Flash并在Activity中嵌入Flash视频 [英] Detect if Flash is installed on Android and embed a Flash video in an Activity

查看:25
本文介绍了检测Android上是否安装了Flash并在Activity中嵌入Flash视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这实际上是一个由两部分组成的问题.首先,是否可以检测 Android 设备上是否安装了 Flash?二、如果安装了,是否可以在Activity中显示flash视频?我认为您必须在您的活动中使用 WebView 小部件来显示 Flash 内容,而不是像 VideoView 这样的东西.WebView 小部件甚至支持 Flash 还是仅由实际的浏览器应用程序支持?

This is really a two part question. First, is it possible to detect if Flash is installed on an Android device? Second, if it is installed, is it possible to display a flash video in an Activity? I'm thinking you'd have to use a WebView widget within your Activity to display the Flash content instead of something like a VideoView. Is Flash even supported within the WebView widget or is it only supported by the actual Browser app?

推荐答案

您对这两部分问题的回答都是是",第二部分取决于第一部分.

The answer to both parts of your questions is "yes", with the second part contingent on the first.

(1) 检测是否安装了 Flash.

(1) Detecting if Flash is installed.

使用 PackageManager 尝试获取 Flash Player 包的应用程序信息.会抛出这样的包不存在的异常.

Use the PackageManager to attempt to obtain the Application Info for the Flash Player package. It will throw an exception of such a package doesn't exist.

boolean flashInstalled = false;
try {
  PackageManager pm = getPackageManager();
  ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
  if (ai != null)
    flashInstalled = true;
} catch (NameNotFoundException e) {
  flashInstalled = false;
}

(2) 如果安装了 Flash,您可以通过将 Flash 视频嵌入 WebView 中来在您的 Activity 中显示它.Flash 插件为 WebView 提供与本机浏览器相同的支持.

(2) Provided Flash is installed, you can display a Flash video within your Activity by embedding it within a WebView. The Flash plugin provides the same support for a WebView as the native browser.

如果您在第 1 部分中的检查返回 false,最佳做法是隐藏您的 WebView 并将其替换为解释 Flash 要求的错误消息,或者更好的是,使用从 Android Market 下载 Flash 插件的链接.

If your check in Part 1 returns false, best practice would be to hide your WebView and replace it with either an error message explaining the requirement for Flash, or better still, a link to download the Flash plugin from the Android Market.

这篇关于检测Android上是否安装了Flash并在Activity中嵌入Flash视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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