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?
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(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); cam.setParameters(p); cam.startPreview();
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(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); cam.setParameters(p); cam.startPreview(); } }
public void flashLightOff() {
cam.stopPreview(); cam.release(); cam = null; }
Then within Gideros
if not native then require "native" end
local bridge = native.getClass("com.giderosmobile.android.plugins.bridge.GBridge") bridge.flashLightOn()
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?
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.
Comments
http://stackoverflow.com/a/6069503
It is just a plugin you need to add to your exported project.
https://github.com/gideros/gideros/tree/master/plugins/native
There html files with instruction on how to add and use
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();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(p);
cam.startPreview();
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.
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
I added this to GBridge.java Then within Gideros 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?
Likes: ar2rsawseen
Likes: hgy29, tytadas