如何检查如果Flash播放器被安装在Android [英] How to check if the Flash players is installed on Android

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

问题描述

我怎么能轻松地检查在Javascript在Android网页浏览器,如果的Adobe Flash Player 10.1(https://market.android.com/details?id=com.adobe.flashplayer)是从Android Market下载并安装?

how can I easily check in Javascript in the Android web browser if the Adobe Flash Player 10.1 (https://market.android.com/details?id=com.adobe.flashplayer) was downloaded from Android Market and installed?

-

更新的:感谢您的答复,但我需要检查$ C $下的 Javascript的,因为我做的基于网页(HTML / JavaScript的/ CSS)解决方案,不是原生的Java应用程序。 Web应用程序的小部分在Flex中完成的,因此.swf文件显示在< D​​IV> 元素,但在此之前这样做,我想,以检查是否Flash播放器安装与否。

Update: Thanks for replies, but I need the check code for Javascript, since I am doing the web based (HTML/Javascript/CSS) solution, not native Java application. Small part of the web application is done in Flex, so .swf file is displayed in <div> element, but prior of doing that I would like to check if Flash Player is installed or not.

推荐答案

有没有你需要检查从Javascript,而不是从Java code什么特殊的原因吗?

Is there any special reason you need to check from Javascript and not from the Java code?

从Java code,你可以做这样的事情:

From Java code, you can do something like this:

    Intent intent = new Intent();

    intent.setComponent(new ComponentName("com.adobe.flashplayer", "com.adobe.flashplayer.FlashExpandableFileChooser"));
    PackageManager pm = getPackageManager();
    List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
    if (activities != null && activities.size() > 0) {
        Toast.makeText(this, "Flash is installed!", Toast.LENGTH_LONG).show();
    }
    else {
        Toast.makeText(this, "Flash not installed!", Toast.LENGTH_LONG).show();
    }

在我的HTC Desire效果很好。

Works well on my HTC Desire.

如果你想知道在哪里我拿com.adobe.flashplayer.FlashExpandableFileChooser类名而来,我只是从Flash播放器的Andr​​oidManifest.xml中抓住了它。

If you're wondering where did I take the com.adobe.flashplayer.FlashExpandableFileChooser class name from, I simply took it from the Flash player's AndroidManifest.xml.

这看起来是这样的:

<?xml version="1.0" encoding="utf-8"?>
<manifest
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:versionCode="101106016"
        android:versionName="10.1.106.16"
        package="com.adobe.flashplayer"
        >
        <application
                android:label="Adobe Flash Player 10.1"
                android:icon="@7F020000"
                >
                <activity
                        android:name="com.adobe.flashplayer.FlashExpandableFileChooser"
                        >
                        <intent-filter
                                >
                                <action
                                        android:name="android.intent.action.MAIN"
                                        >
                                </action>
                                <category
                                        android:name="android.intent.category.DEFAULT"
                                        >
                                </category>
                                <category
                                        android:name="FlashExpandableFileChooser"
                                        >
                                </category>
                        </intent-filter>
                </activity>
                <service
                        android:name="com.adobe.flashplayer.FlashPaintSurface"
                        >
                        <intent-filter
                                >
                                <action
                                        android:name="android.webkit.PLUGIN"
                                        >
                                </action>
                        </intent-filter>
                        <meta-data
                                android:name="type"
                                android:value="native"
                                >
                        </meta-data>
                </service>
        </application>
        <uses-permission
                android:name="android.webkit.permission.PLUGIN"
                >
        </uses-permission>
        <uses-sdk
                android:minSdkVersion="8"
                android:targetSdkVersion="5"
                android:maxSdkVersion="10"
                >
        </uses-sdk>
</manifest>

您可以按照指示这里如何调用这个code从你的JavaScript code。 具体看setJavaScriptInterface方法

You can follow the instructions here on how to call this code from your JavaScript code. Specifically look at the setJavaScriptInterface method

要直接从JavaScript的检测,使用此片段:

To detect directly from JavaScript, use this snippet:

flashInstalled = false;
if (navigator.plugins && navigator.plugins.length) {
  for (n = 0; n < navigator.plugins.length; n++) {
    if (navigator.plugins[n].name.indexOf('Shockwave Flash') != -1) {
        flashInstalled = true;
        break;
    }
}

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

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