Skip to content

Commit

Permalink
fix more camera state issues found in Android 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Jan 20, 2018
1 parent 88432ed commit 07f1c5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/main/java/org/havenapp/main/MonitorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,6 @@ private void configCamera() {

mFragmentCamera.stopCamera();
startActivityForResult(new Intent(this, CameraConfigureActivity.class),REQUEST_CAMERA);
/**
String camera = preferences.getCamera();
if (camera.equals(PreferenceManager.FRONT))
preferences.setCamera(PreferenceManager.BACK);
else if (camera.equals(PreferenceManager.BACK))
preferences.setCamera(PreferenceManager.FRONT);
((CameraFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_camera)).resetCamera();
**/

}


Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/havenapp/main/sensors/motion/Preview.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public void addListener(MotionAsyncTask.MotionListener listener) {
*/
public void surfaceCreated(SurfaceHolder holder) {

if (camera != null)
stopCamera();
/*
* The Surface has been created, acquire the camera and tell it where
* to draw.
Expand All @@ -167,7 +169,6 @@ public void surfaceCreated(SurfaceHolder holder) {
}
break;
case PreferenceManager.BACK:

camera = Camera.open();
cameraFacing = Camera.CameraInfo.CAMERA_FACING_BACK;
break;
Expand Down Expand Up @@ -346,7 +347,9 @@ public void stopCamera ()
// Surface will be destroyed when we return, so stop the preview.
// Because the CameraDevice object is not a shared resource, it's very
// important to release it when the activity is paused.
context.unbindService(mConnection);
if (serviceMessenger != null)
context.unbindService(mConnection);

camera.setPreviewCallback(null);
camera.stopPreview();
camera.release();
Expand Down

0 comments on commit 07f1c5f

Please sign in to comment.