Simple Android Flashlight app
Your inner if-else is incorrect, and that's why it's not working under Marshmallow.

if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
    if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        System.out.println("Check : has permission");
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1);
        handleFlash();
    }
} else {
    handleFlash();
}