title: new android Camera2 Api on nexus 7
body: <p>I have a problem with android Camera2 API on a Nexus 7. I have developed an app on android 4.4.4 that uses the camera to take a picture, and I want to update it for the Lollipop update. I've followed code from this link to make new camera api work: <a href="https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java" rel="nofollow">https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java</a></p>
  
  <p>I've tested code on a Nexus 5, and everything works well, but if i try it on a Nexus 7, something goes wrong. This is the error log:</p>
  
  <pre><code>12-17 17:01:15.517: W/LegacyRequestMapper(24382): convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
  12-17 17:01:15.517: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
  12-17 17:01:15.518: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
  12-17 17:01:15.519: W/LegacyRequestMapper(24382): mapAeAndFlashMode - Ignore control.aeMode == ON_AUTO_FLASH;camera does not support it
  12-17 17:01:15.519: W/LegacyRequestMapper(24382): convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
  12-17 17:01:15.955: I/CameraDeviceState(24382): Legacy camera service transitioning to state CAPTURING
  12-17 17:01:21.198: I/RequestQueue(24382): Repeating capture request cancelled.
  12-17 17:01:21.198: I/RequestQueue(24382): Repeating capture request set.
  12-17 17:01:21.215: W/LegacyRequestMapper(24382): convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
  12-17 17:01:21.215: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
  12-17 17:01:21.215: W/LegacyRequestMapper(24382): Only received metering rectangles with weight 0.
  12-17 17:01:21.216: W/LegacyRequestMapper(24382): mapAeAndFlashMode - Ignore control.aeMode == ON_AUTO_FLASH;camera does not support it
  12-17 17:01:21.216: W/LegacyRequestMapper(24382): convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
  12-17 17:01:21.495: E/AndroidRuntime(24382): FATAL EXCEPTION: CameraBackground
  12-17 17:01:21.495: E/AndroidRuntime(24382): Process: com.example.newapicamera, PID: 24382
  12-17 17:01:21.495: E/AndroidRuntime(24382): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at com.example.newapicamera.Camera2BasicFragment$4.process(Camera2BasicFragment.java:285)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at com.example.newapicamera.Camera2BasicFragment$4.onCaptureCompleted(Camera2BasicFragment.java:324)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at java.lang.reflect.Method.invoke(Native Method)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at java.lang.reflect.Method.invoke(Method.java:372)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.Handler.handleCallback(Handler.java:739)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at  android.os.Handler.dispatchMessage(Handler.java:95)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.Looper.loop(Looper.java:135)
  12-17 17:01:21.495: E/AndroidRuntime(24382):    at android.os.HandlerThread.run(HandlerThread.java:61)
  12-17 17:01:21.542: I/RequestQueue(24382): Repeating capture request cancelled.
  12-17 17:01:21.580: E/BufferQueueProducer(24382): [unnamed-24382-2] dequeueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.580: E/BufferQueueProducer(24382): [unnamed-24382-2] dequeueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.596: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.605: W/Camera-JNI(24382): callback on dead camera object
  12-17 17:01:21.620: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.651: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.688: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
  12-17 17:01:21.721: E/BufferQueueProducer(24382): [unnamed-24382-2] queueBuffer: BufferQueue has been abandoned
  </code></pre>
  
  <p>The line that throws the exception is:</p>
  
  <pre><code>int aeState = result.get(CaptureResult.CONTROL_AE_STATE);
  </code></pre>
  
  <p>What is going wrong?</p>