Hello everyone
I created pull request in processing for android a month back, It’s already approved. Any mentor please review or merge it.
Thanks
Hello everyone
I created pull request in processing for android a month back, It’s already approved. Any mentor please review or merge it.
Thanks
Meanwhile code below is working on my Samsung S4 Lollipop (Although depricated )
I’ll try to write a code for newer camara mode
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
public static Camera cam = null;
boolean on;
void setup () {
cam = Camera.open();
}
void draw () {
}
void mousePressed () {
Parameters p = cam.getParameters();
if (p.getFlashMode() != null) {
if (on) {
p.setFlashMode(Parameters.FLASH_MODE_OFF);
cam.setParameters(p);
cam.stopPreview();
} else {
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(p);
cam.startPreview();
}
}
on = ! on;
}
void onStop () {
cam.release();
cam = null;
}
@pallav12
I remembered that the Ketai lib also handles flashlight. You can find the code here
You can find the related code beginning at line 390. It does however also use the “Camara api”, not the newer camara2.
If you have a device using android above lollipop, please comment if you have any problems.
Thanks @noel that works great… I just thought that there should be a built in method in PApplet since opening flashlight is a basic android function.
Please tell me the name of android version and device that you used.
@noel sorry for the late reply… its Oreo 8.1, oppo A3s