@Override public void onDestroy() { super.onDestroy(); Log.v(TAG, "onDestroy: service destroyed"); if (mCameraDevice.isFlashlightOn()) { Log.w(TAG, "Flashlight still on"); if (!mCameraDevice.toggleCameraLED(false, false)) { Log.e(TAG, "Cannot toggle camera LED"); } } // mCameraDevice.stopPreview(); // handled in surface callback mCameraDevice.releaseCamera(); mCameraDevice = null; // remove the overlay WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); wm.removeView(mOverlay); mOverlay = null; mSurfaceView = null; }
@SuppressWarnings("deprecation") @Override public void onCreate() { super.onCreate(); Log.v(TAG, "onCreate: service starting"); mCameraDevice = new CameraDevice(); mCameraDevice.acquireCamera(); createOverlay(); // this gives us the surface view the camera device needs SurfaceHolder holder = mSurfaceView.getHolder(); holder.addCallback(new SurfaceKeeper()); // deprecated holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }