Skip to content

Commit

Permalink
Fix leaked service handler bound in Preview
Browse files Browse the repository at this point in the history
Ref. issues: #258 #248
  • Loading branch information
lukeswitz committed Mar 1, 2018
1 parent dad248a commit 7800be3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/havenapp/main/sensors/motion/Preview.java
Expand Up @@ -124,8 +124,9 @@ public Preview (Context context) {
/*
* We bind to the alert service
*/
context.bindService(new Intent(context,
MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);}
this.context.bindService(new Intent(context,
MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);
}

public void setMotionSensitivity (int
motionSensitivity )
Expand Down Expand Up @@ -393,8 +394,7 @@ 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.
if (serviceMessenger != null)
context.unbindService(mConnection);
this.context.unbindService(mConnection);

camera.setPreviewCallback(null);
camera.stopPreview();
Expand Down
Expand Up @@ -126,6 +126,7 @@ public void onBackPressed() {
@Override
public void onResume() {
super.onResume();
mFragment.stopCamera();
}

@Override
Expand Down

0 comments on commit 7800be3

Please sign in to comment.