Skip to content
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

How to turn on a flashlight on a phone with Android 9? #668

Open
Andrukva opened this issue Mar 7, 2022 · 8 comments
Open

How to turn on a flashlight on a phone with Android 9? #668

Andrukva opened this issue Mar 7, 2022 · 8 comments

Comments

@Andrukva
Copy link

Andrukva commented Mar 7, 2022

Please tell me how to turn on the flashlight on a phone with Android 9 using plyer and kivy/switch or kivy/button. Those examples that exist do not work. The application starts, but as soon as I press the button to turn on the flashlight, the application closes. Please show me how to do it correctly. Thank you in advance!

@HyTurtle
Copy link
Contributor

HyTurtle commented Mar 7, 2022

Android Permissions would be needed to be granted for various plyer/pyjnius features - for flash(light) have you requested CAMERA permission?

Otherwise could you get a crash report via logcat - to see a reason for the crash.

@Andrukva
Copy link
Author

Andrukva commented Mar 7, 2022

I requested permission when assembling in a bulldozer, as shown in the example.

@Andrukva
Copy link
Author

Andrukva commented Mar 7, 2022

I requested permission for both the camera and the flashlight.

@HyTurtle
Copy link
Contributor

HyTurtle commented Mar 7, 2022

Just checked and flash.on() and flash.off() runs fine here on Android 11. Did you request camera at runtime ie within the app.
If not you can do so manually with your current app in Settings > Apps

Otherwise again - would ideally want to see the log report.

@Andrukva
Copy link
Author

Andrukva commented Mar 7, 2022

Could you show me what code you tried?

@Andrukva
Copy link
Author

Andrukva commented Mar 7, 2022

Strangely, my application is not in the list of applications that are allowed or not allowed to use the camera. Although in the specification of the bulldozer I specified both the camera and the flash

@oukiar
Copy link

oukiar commented Oct 23, 2022

I think this issue was solved by this pull request #716

Tested under android 5.

If you want to test change the requirements in your buildozer.spec
requirements = kivy, git+https://github.com/oukiar/plyer.git

and do buildozer android clean

best regards

@oukiar
Copy link

oukiar commented Oct 23, 2022

Some updates, today i was able to test in android 9 and my surprise is that using the legacy camera api not work.

For get working the flashlight was added code for use the CameraManager (newer api) now it is working and tested on android 9 device, maybe will work on other android versions, tests are necesary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants