• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Use camera flash

gethan

Lurker
Hey,
i tried to make an app, than can switch my camera flash on and off.
The code i have atm looks like this:
PHP:
        Camera flash;
        Camera.Parameters params;
        
        flash = Camera.open();
        params = flash.getParameters();
        
        params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);        
        flash.setParameters(params);

and in the manifest xml:
PHP:
 <permission android:name="android.permission.FLASHLIGHT"  
             android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
             android:protectionLevel="normal" />
    <permission android:name="android.permission.CAMERA"></permission>

Everytime i run the code, the app crashes.

What is wrong?
 
Back
Top Bottom