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) 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With