Turn on FlashLight with android native extension

// Expert user has replied.
M Mauro Soro 3 years 6 months ago
112 1 0

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 in the build.yml/extensions
run rhodes extension inside the project folder
changed the section inside the xml file in this location extensions//ext/.xml and run the command rhodes api .xml in the extensions//ext folder
changed the method inside extensions//ext/platform/android/src/com/rho//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

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

Please Register or Login to post a reply

1 Replies

B Bhakta Ranjan Satapathy

Hi,

Flashlight feature while capturing photo available in 2.2 Camera Api.
http://docs.rhomobile.com/en/2.2.0/rhodesapi/camera-api#takepicture

Camera::take_picture(callback_url, options_hash)

options_hash for iOS and Android Devices
options_hash is a hash used with take_picture and choose_picture on iOS and Android.
flash_mode (Android only) String. "off", "on", "auto", "red-eye", "torch".

Thanks

CONTACT
Can’t find what you’re looking for?