简体   繁体   English

手电筒在nexus 5 android 6.0.1中不起作用

[英]Flashlight not working in nexus 5 android 6.0.1

I am new in android . 我是android新手。 i implemented code for flashlight on and off while ringing call .so this code work for every device but in nexus 5 its not working .i debug and try to find out issue but nothing do (no force close, no flash on-off). 我在拨打电话时打开和关闭手电筒的代码。这个代码适用于每个设备,但是在nexus 5中它不工作.i调试并尝试找出问题但没有做(没有强制关闭,没有闪存开关)。

Camera.Parameters pon;
Camera cam;

pon = cam.getParameters();
pon.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

control goes up to abov line but still its not working please help me how to fix this issue 控制上升到abov线但仍然无法正常工作请帮我解决这个问题

target version is 22 compile with 22 目标版本是22用22编译

You have to config your build.gradle to work with Android 6.0 --> API 23 您必须将build.gradle配置为使用Android 6.0 - > API 23

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "your.app"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM