surfaceCreated : java.lang.NullPointerException

前端 未结 2 746
刺人心
刺人心 2021-01-12 17:19

I am trying to make Custom Camera app, but whenever i run my program,

getting -

Unfortunately App has Stopped

Log

2条回答
  •  难免孤独
    2021-01-12 17:59

    Here you mCamera is returning null. This is due to improper initialization of camera. Use Camera.open(); to initialize it. Also check for any exceptions thrown in process of initialization. Also make sure that you have all necessary permissions in manifest file

    
    
    
    
    
    
    
    
     try {
        camera = Camera.open();
        Log.d(CameraCaptureActivity.LOG_TAG, "getCameraInstance()open:: " + camera);
    } catch (Exception e) {
        // Check here for any exceptions
    }
    

提交回复
热议问题