Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to release camera when people stop using your widget?

I've built a widget which uses the camera for it's flashlight, It works perfectly turning on and off, and releasing it when people actually turn it off, but if I turn it on and then I go to the camera, it of course crashes the camera app, how do I release the camera in case a user forgets to turn off the flashlight? Is there a way to detect when a new app is about to be started before it calls on the camera?

like image 729
Bbit Avatar asked Nov 01 '22 12:11

Bbit


1 Answers

Based on my research, this is impossible on default android devices, Samsung achieved this with one of their apps, but this was most likely due to their enhancement of basic android features. This would mean however that they would need to release a documentation on how this is achieved and it would only work on the phones that they've enabled this on.

If anyone else has an answer which is actually useful rather then specifying why this can't be done, I'd be happy to accept it, I'll leave this here hoping other people see it and don't waste their time researching the subject for as long as I did.

*Edit, if google would somehow update the OS to allow apps to check if the camera is used and if it was, to free it, then this would easily work, but alas, we got to wait for them. Or develop on Iphone where you don't need to contact the camera to access the flash.

like image 67
Bbit Avatar answered Nov 12 '22 16:11

Bbit