<bdo id='whODz'></bdo><ul id='whODz'></ul>
    1. <small id='whODz'></small><noframes id='whODz'>

    2. <i id='whODz'><tr id='whODz'><dt id='whODz'><q id='whODz'><span id='whODz'><b id='whODz'><form id='whODz'><ins id='whODz'></ins><ul id='whODz'></ul><sub id='whODz'></sub></form><legend id='whODz'></legend><bdo id='whODz'><pre id='whODz'><center id='whODz'></center></pre></bdo></b><th id='whODz'></th></span></q></dt></tr></i><div id='whODz'><tfoot id='whODz'></tfoot><dl id='whODz'><fieldset id='whODz'></fieldset></dl></div>
    3. <tfoot id='whODz'></tfoot>
    4. <legend id='whODz'><style id='whODz'><dir id='whODz'><q id='whODz'></q></dir></style></legend>

      使用 kivy/python 访问 android 手电筒(相机 LED 闪光灯

      时间:2023-09-01

      <i id='LxyLc'><tr id='LxyLc'><dt id='LxyLc'><q id='LxyLc'><span id='LxyLc'><b id='LxyLc'><form id='LxyLc'><ins id='LxyLc'></ins><ul id='LxyLc'></ul><sub id='LxyLc'></sub></form><legend id='LxyLc'></legend><bdo id='LxyLc'><pre id='LxyLc'><center id='LxyLc'></center></pre></bdo></b><th id='LxyLc'></th></span></q></dt></tr></i><div id='LxyLc'><tfoot id='LxyLc'></tfoot><dl id='LxyLc'><fieldset id='LxyLc'></fieldset></dl></div>
        <tbody id='LxyLc'></tbody>
            • <small id='LxyLc'></small><noframes id='LxyLc'>

            • <legend id='LxyLc'><style id='LxyLc'><dir id='LxyLc'><q id='LxyLc'></q></dir></style></legend>

              <tfoot id='LxyLc'></tfoot>
                <bdo id='LxyLc'></bdo><ul id='LxyLc'></ul>
                本文介绍了使用 kivy/python 访问 android 手电筒(相机 LED 闪光灯)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我不知道如何使用 python 或 kivy 访问我的 android 上的 led 灯,我尝试安装 python-for-android 以便能够将 android 模块导入我的代码,但它不是模块可以'找不到.我按照此处的说明克隆了 python-for-android.我没有按照我想的那样按照该页面安装 ndk 或 sdk,因为 kivy 已经使用它们,它们已经安装了.有人可以指出我正确的方向吗?

                I can't figure out how to access the led light on my android with python or kivy, I have tried installing python-for-android to be able to import the android module into my code but it's not the module can't be found. I cloned python-for-android as instructed here. I didn't install the ndk or sdk as per that page as I thought since kivy already uses them they were already installed. Can someone please point me in the right direction?

                推荐答案

                是的,你可以从桌面用 Kivy 编写这个应用程序,只是无法在桌面上测试它.每次都必须构建并部署到 Android 设备上进行测试.

                Yes, you can write this app in Kivy from the desktop, you just won't be able to test it on the desktop. You will have to build and deploy to an Android device to test each time.

                改编自如何在Android中以编程方式打开相机闪光灯?:

                检查闪存功能是否可用:

                To check if flash capability is available:

                PythonActivity = autoclass('org.renpy.android.PythonActivity')
                PackageManager = autoclass('android.content.pm.PackageManager')
                pm = PythonActivity.mActivity.getPackageManager()
                flash_available = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
                

                要使用手电筒,您的应用需要 FLASHLIGHT 和 CAMERA 权限.您可以将这些添加到 buildozer.spec 或 python-for-android 命令行.

                To use the flashlight, your app will need the FLASHLIGHT and CAMERA permissions. You can add these to buildozer.spec or the python-for-android command line.

                最后,打开闪光灯:

                Camera = autoclass('android.hardware.Camera')
                CameraParameters = autoclass('android.hardware.Camera$Parameters')
                cam = Camera.open()
                params = cam.getParameters()
                params.setFlashMode(CameraParameters.FLASH_MODE_TORCH)
                cam.setParameters(params)
                cam.startPreview()
                

                然后关闭:

                cam.stopPreview()
                cam.release()
                

                这篇关于使用 kivy/python 访问 android 手电筒(相机 LED 闪光灯)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:仅使用 kv 文件在 kivy 中创建 DropDown 下一篇:如何使用 kivy 打开默认的 Android 应用程序?

                相关文章

                最新文章

                  <small id='s4oRO'></small><noframes id='s4oRO'>

                1. <legend id='s4oRO'><style id='s4oRO'><dir id='s4oRO'><q id='s4oRO'></q></dir></style></legend>
                    <tfoot id='s4oRO'></tfoot>
                    <i id='s4oRO'><tr id='s4oRO'><dt id='s4oRO'><q id='s4oRO'><span id='s4oRO'><b id='s4oRO'><form id='s4oRO'><ins id='s4oRO'></ins><ul id='s4oRO'></ul><sub id='s4oRO'></sub></form><legend id='s4oRO'></legend><bdo id='s4oRO'><pre id='s4oRO'><center id='s4oRO'></center></pre></bdo></b><th id='s4oRO'></th></span></q></dt></tr></i><div id='s4oRO'><tfoot id='s4oRO'></tfoot><dl id='s4oRO'><fieldset id='s4oRO'></fieldset></dl></div>
                      <bdo id='s4oRO'></bdo><ul id='s4oRO'></ul>