-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin still running after navigator.app.exitApp() #3
Comments
Hi, are you calling exitapp in the callback handler of switchoff? If not, do you give the switchoff function sufficient time to perform the actual switch? |
Hi, no I*m not calling exitapp in the callback of switchoff. Could you please show how? It seems like enough time to switchoff to perform the actual switch, because if the camera is on and i press the backbutton, the switch is turned off before the app is closing. My code looks like this: Thanks for quick response Eddy :> |
Hi, try it like this and let me know what happens. It defines a callback function (exitApp) which is invoked when the switchOff function returns from native code back to Javascript (the callback): function exitApp() { document.addEventListener("backbutton", function(){ |
I see what you're thinking, but somehow it seems like the same (except now we're 100% sure that the flashlight.switchOff is finished). The flashlight is shutdown, and exitApp is called and everything is looking alright. But it still runs in the background even though the app isnt running... The only way to fix it is to go to the Task Manager and force stop the app. May that be an indicator that the app is not exited properly, but on the other hand the app disappears from "running apps" in task manager when backbutton is pushed... Kinda a contradiction. |
Hi, I will try to find some time and try this myself. One more question: does switchOff work in other cases (not while exiting the app)? If so, you could try wrapping exitApp in a timeout to give it some more time to switch the light off: setTimeout(function() { |
Hi, yes, switchOff work in other cases just fine. I tried your suggestion, but it doesn't help. :( I think the problem may be that flashlight.switchOff() is not "complete", even though the flash is shut off, it still occupies the camera. Because if the flashlight is toggled off and the app is shutdown (without having to call switchOff()) the camera is still occupied. Would you like me to push my code so you could try it yourself? It's just about 10 lines of code for the flashlight. |
Yes please do. Thanks! |
Here it is :) |
1 similar comment
Here it is :) |
Hi! You're on to something... when exiting the app with exitApp (and after switching the light off), the camera seems to remain occupied. |
Hi @HuaHub, I was able to fix the problem you reported! I've just submitted it to the repo and PhoneGap Build. I've added your github name to the README credits because I think it was quite an import bugfix for Android developers. Thanks again for pointing this out to me, |
The flashlight still runs after navigator.app.exitApp() is called.
It doesn't help to use "window.plugins.flashlight.switchOff();", it is still running which makes it impossible for other apps to use the camera if the flashlight app isn't forced stopped.
Solution?
The text was updated successfully, but these errors were encountered: