cordova - phonegap android check if device has flash -


i create app android phonegap 3.0 , want check if device has flash ligth have problems method of getpackagemanager() medthod,

here part of java file, no errors compiling on device plugin not work:

    ...     import android.content.context;     import android.content.pm.packagemanager;      public class torch extends cordovaplugin {         camera camera;       camera.parameters parameters;       boolean hasflash;       context my_service;      /*  constructor */         public torch() {  }          public boolean execute(string action, jsonarray args, callbackcontext callbackcontext) throws jsonexception {              if (action.equals("shine")) {                     hasflash = my_service.getpackagemanager().hassystemfeature(packagemanager.feature_camera_flash);                     if (!hasflash) {  callbackcontext.error("no torch found");  }                      else { this.shine(args.getboolean(0));          } ... 

i tried code in eclipse, there works without context my_service instance.

hasflash = getapplicationcontext().getpackagemanager()                 .hassystemfeature(packagemanager.feature_camera_flash);          if (!hasflash) { ... 

try this

    boolean hasflash = this.cordova.getactivity().getpackagemanager()                 .hassystemfeature(packagemanager.feature_camera_flash); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -