I am trying to implement a solution that I found HERE but after I hit capture, the back button doesn't finish the activity. Is there a way to call
finish();
when the back button is pressed within the function
private void capture() {
mCamera.takePicture(null, null, null, new Camera.PictureCallback() {
final float bearing = degree;
@Override
public void onPictureTaken(byte[] data, Camera camera) {
latitude = mGpsLocationTracker.getLatitude();
longitude = mGpsLocationTracker.getLongitude();
Toast.makeText(getApplicationContext(), "Picture Taken",
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "" +
latitude + ", " + longitude, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "" + bearing, Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.putExtra("image_arr", data);
setResult(RESULT_OK, intent);
camera.stopPreview();
if (camera != null) {
camera.release();
mCamera = null;
}
finish();
}
});
}
@Override
public void onBackPressed() {
super.onBackPressed();
finish();
}