1

I am new in 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).

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

target version is 22 compile with 22

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
sunita
  • 470
  • 1
  • 6
  • 22

1 Answers1

0

You have to config your build.gradle to work with 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'
}
Miguel Benitez
  • 2,322
  • 10
  • 22