2 Replies Latest reply on Jul 24, 2014 2:41 AM by Mauro Soro

    Turn on FlashLight with android native extension

    Mauro Soro

      Hi all,

       

      I would try to turn on the flashlight of the camera phone, if supported, using native android code.

      I am using RhoStudio v 4.0.0, java jdk1.7.0_45, java jre 7, android ndk r9d and sdk for android 4.4(API 19).

       

      Following the guide I do the following action

       

      • Added <extension-name> in the build.yml/extensions
      • run rhodes extension <extension-name> inside the project folder
      • changed the section <METHODS> inside the xml file in this location extensions/<extension name>/ext/<extension name>.xml and run the command rhodes api <extension-name>.xml in the extensions/<extension-name>/ext folder
      • changed the method inside extensions/<extension-name>/ext/platform/android/src/com/rho/<extension-name>/<extension-name>Singleton.java with the following code

               Camera camera = Camera.open();
               final Parameters p = camera.getParameters(); p.setFlashMode(Parameters.FLASH_MODE_ON);
      camera.setParameters(p); camera.startPreview();

      • modified the AndroidManifest.xml inside the folder C:\MotorolaRhoMobileSuite4.0.0\ruby\lib\ruby\gems\1.9.1\gems\rhodes-4.0.0\platform\android\Rhodes adding
        • <uses-permission android:name="android.permission.CAMERA" />
          <uses-feature android:name="android.hardware.camera" />
          <uses-feature android:name="android.hardware.camera.autofocus" />

       

      When I run my app with the test app, the code does not work. I can connect to the camera (rhostudio capabilities) but I can't turn on the flashlight (in a native application the android code works).

       

      No other has difficulties to integrate a native extensions?

      Can someone help me with some troubleshooting or with a sample code?

       

      Thanks, best regards,

      Mauro