Checking users installed flash version


SDK Version: 
M3

Here is a little tutorial on checking users flash version. It comes in handy, if you want to use flash content in your app. Flash lite can cause some problems, so this snippet is also about that...

We have several android phones in the office, and all phones with HTC Sense UI had problems with webviews and flash content. Some crashed, some did not show flash content. It seems, that the webview does not use the proper flash player, if it has both flash lite and flash player installed. It simply chooses "none", or crashes.

  1. public static boolean checkFlash() {
  2.         PackageManager pm = ContextProvider.getContext().getPackageManager();
  3.         try {
  4.                 //check flash
  5.                 ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
  6.                 Log.d("Flash version Installed: " + pm.getPackageInfo("com.adobe.flashplayer", 0).versionName);
  7.                 if (ai != null) {
  8.                         Log.d("flash present...OK");
  9.                 }
  10.         } catch (NameNotFoundException e) {
  11.                 return false;
  12.         }
  13.         try {
  14.                 //check flash lite
  15.                 ApplicationInfo ai2 = pm.getApplicationInfo("com.htc.flashliteplugin", 0);
  16.                 if (ai2 != null) {
  17.                         Log.d("flash lite present..disabling flash");
  18.                         return false;
  19.                 }
  20.                 return true;
  21.         } catch (NameNotFoundException e) {
  22.                 return true;
  23.         }
  24. }
  25.  
  26. //you also need to enable/disable webview plugins to use or disable flash:
  27. webview.getSettings().setPluginsEnabled(true)

So for now, we just disable flash altogether if flash lite is present. If anyone knows a workaround or a solution, please leave a comment.