Android 棉花糖中手电筒的申请许可代码是什么?

Android 棉花糖中手电筒的申请许可代码是什么?,android,android-fragments,android-6.0-marshmallow,Android,Android Fragments,Android 6.0 Marshmallow,我想在marshmallow6.0中打开或关闭手电筒,因为在android中运行时需要授予权限。我尝试了请求权限代码,但它不起作用 代码: (它无法工作,因为我无法获取android.manifest.permission.FLASHLIGHT) 任何人都能解决这个问题 提前感谢。我想该设备没有闪光灯。您是否使用了功能是的,我在清单文件中使用了此权限。 if((ContextCompat.checkSelfPermission(getActivity(),Manifest.permission.

我想在marshmallow6.0中打开或关闭手电筒,因为在android中运行时需要授予权限。我尝试了请求权限代码,但它不起作用

代码:

(它无法工作,因为我无法获取android.manifest.permission.FLASHLIGHT)

任何人都能解决这个问题


提前感谢。

我想该设备没有闪光灯。您是否使用了功能是的,我在清单文件中使用了此权限。
if((ContextCompat.checkSelfPermission(getActivity(),Manifest.permission.FLASHLIGHT)  != PackageManager.PERMISSION_GRANTED) ||
                (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA)  != PackageManager.PERMISSION_GRANTED)){
            // user permission not granted
            // ask permission
            requestPermissions(new String[]{Manifest.permission.FLASHLIGHT, Manifest.permission.CAMERA});
        }
        else{
            // user already provided permission
        }