jLab19
jLab19

Reputation: 27

Camera Error with SurfaceView

This is my AndroidManifest.xml:

<permission android:name="android.permission.FLASHLIGHT"
        android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
        android:protectionLevel="normal"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.sensor.accelerometer"
        android:required="true"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-feature android:name="android.hardware.camera"/>
    <uses-feature android:name="android.hardware.camera.flash"/>

this is my log

05-01 20:58:29.235 13175-13175/rp.com.lumos E/Camera-JNI: android_hardware_Camera_native_setup Error: -1 
05-01 20:58:29.235 13175-13175/rp.com.lumos E/Camera: Camera new cameraInitNormal:-1

This code witch I call camera:

try {
                                camera = Camera.open();
                            } catch (RuntimeException e) {
                                System.err.println(e);
                                return;
                            }
                            Camera.Parameters params;
                            params = camera.getParameters();
                            param.setFlashMode(android.hardware.Camera.Parameters.FLASH_MODE_TORCH);
                            ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(1100);
                            camera.setParameters(param);
                            try {
                                camera.setPreviewDisplay(holderSurf);
                                camera.startPreview();

                            } catch (Exception e) {
                                System.err.println(e);
                                return;
                            }

When Activity start I found the error in my log...What did I do wrong?

Upvotes: 0

Views: 560

Answers (1)

KLPA
KLPA

Reputation: 67

I was running into the same problem, when testing on my Huawei P8 lite (Android 6.0). I solved it by adding the camera permission on my phone:

Settings -> Apps -> (click on app) -> permissions -> camera

Upvotes: 1

Related Questions