Does playing swf in Android2.2 requires an external Flash Player to be installed?

385 views Asked by At

I would like to use swf animations in my application. 1. Is it possible to do so without Adobe Flash Player installed, using a library for example? 2. If so, how? If not, is there a way to check that the player is installed or "mark" it as required? 3. Should it work on the emulator?

1

There are 1 answers

0
K_Anas On BEST ANSWER

Yes You can use swf animation on android, the way this works consist on:

creating an html page in wich you play the swf, then opening the html in a webview component

You should first check if Flash is installed this snippet can help you:

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;
}

By using the PackageManager you can obtain the Application Info for the Flash Player package. It will throw an exception if such a package doesn't exist.

After that you can display a Flash video to play your animation within your Activity by embedding it within a WebView.

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.

yes you can test it on emulator after installing Flash app on it!!