Detect if Flash is installed on Android and embed a Flash video in an Activity

前端 未结 1 480
感情败类
感情败类 2020-12-07 20:57

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 fla

1条回答
  •  太阳男子
    2020-12-07 21:42

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

    (1) Detecting if Flash is installed.

    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) 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.

    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.

    0 讨论(0)
提交回复
热议问题