Android Flashlight App Stops Working
I have been writing a simple flash light app that has an on/off toggle button. The app starts and I click the 'on' button the flash comes on a stays on until I click the 'off' but
Solution 1:
Ah! It is working now. I had to modify my turnFlashOn() method like so:
public void turnFlashOn() {
Log.i(TAG, "[42] turnFlashOn()");
if (cam == null) {
Log.i(TAG, "turnFlashOn() step 1");
cam = Camera.open();
Log.i(TAG, "[64] turnFlashOn() cam was null. Camera.open() called");
/* new stuff */
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
Log.i(TAG, "[174] turnFlashOn() calling initCamera(surfaceHolder) hasSurface is " + hasSurface );
initCamera(surfaceHolder);
/* end new stuff */
}
Post a Comment for "Android Flashlight App Stops Working"