Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Camera Flashlight - Gideros Forum

Camera Flashlight

rikolousrikolous Member
edited October 2015 in Plugins
Is there a way to access the devices flash from the camera? I just need to be able to turn it on and off from my app.


  • Sounds hard, but I am up for it. lol. Is there a good example how to set up a native bridge?
  • Ok forget Native Bridge for now because I am going to start with Android anyway. So the solution from http://stackoverflow.com/a/6069503 seems to be dealing with what code I write in my main activity which I am doing from Eclipse. I have also downloaded an example flashlight code which is slightly different but also I run it out of Eclipse. So I am confident I can do it. I guess what I need to know is how to code in gideros and eclipse so they work with each other. Is there an example of doing this or another thread that explains what I need to know?
  • That would be Native bridge :)

    It is just a plugin you need to add to your exported project.


    There html files with instruction on how to add and use ;)
  • You have been so helpful. I must admit I feel overwhelmed with this one. BUT I won't quit til I get it. A few questions about Native Bridge.

    Is Native bridge supposed to have a .dll so that it works in Gideros on windows? The example works only when I use it through Eclipse.

    Second, and more importantly, is there a simple way to plug this all in without knowing Java? Do I have to write a lot of code in my Main Activity for on Eclipse? For example this code given on Stack Overflow:

    Camera cam = Camera.open();
    Parameters p = cam.getParameters();

    I have no Idea where to plug it in on Eclipse or how to change it in Gideros so that it works. I have tried so many things too. I know there was more of an explanation and elaborate code on that same Stack overflow thread. That was even more confusing.

    If I could just get the Flash to turn on I could do the rest. I'm just stumped though.
  • @rikolous unfortunately native bridge is Android only so it will work only on Android.

    About java code, you can create 2 methods in Bridge class, like turnFlashlightOn and turnFlashlightOff and copy the code from stack overflow there. Then add any dependencies that eclipse is shouting about when trying to build.
    And in the end simply get bridge class in lua and call your created methods
  • Okay, I normally try for a few days before asking another question. Its been like a day and a half.

    I added this to GBridge.java
    public static Camera cam = null;

    public void flashLightOn() {

    Camera cam = Camera.open();
    Parameters p = cam.getParameters();

    public void flashLightOff() {

    cam = null;
    Then within Gideros

    if not native then
    require "native"

    local bridge = native.getClass("com.giderosmobile.android.plugins.bridge.GBridge")
    I have added both camera and flash permissions. Using getPackageManager creates issues when I have it check my phone for flash.

    I have done this amongst many other things I have tried. But I am not having any luck. I have used this example to make sure that it isn't my phone: http://www.androidhive.info/2013/04/android-developing-flashlight-application/ It works just fine. I also tried refining this code and putting it into GBridge.java but still no results. Do you see anything blaring that I am doing wrong?
  • rikolousrikolous Member
    edited October 2015
    Nevermind... I didn't add "static". Only a few moments after I wrote this I tried that after at least 5 hours of trying things. Public STATIC void. Well thanks for all your help.

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 ) Share on Facebook
  • Isn't it funny how a public post sharpens the mind?! :) Happens to me all the time.

    Likes: hgy29, tytadas

    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 ) Share on Facebook
Sign In or Register to comment.