Black Screen


After entering all code in Chapter 19, I get a black screen next to the Take button when I hit the camera icon. My problem is that the mCamera variable is null. My onResume() method with debug logging follows:

public void onResume() {
		 Log.d(TAG, "*** new OS with mCamera: " + mCamera);
	 } else {
		 mCamera =;
		 Log.d(TAG, "*** old OS with mCamera: " + mCamera);

I have a new Nexus 7 with two cameras and have tried using both 0 and 1 as the argument. The results are the same –

    04-12 18:11:27.331: D/CrimeCameraFragment(8748): *** new OS with mCamera: null

Thanks for any suggestions.


Here are my results with Nexus devices:
Nexus 5 (2 cameras): Worked and used rear camera
Nexus 7 2012 (1 camera): Worked.
Nexus 7 2013 (2 cameras): Worked and used rear camera


I had a black screen issue as well, though all the code was correct.
Then I tried the following snippet to open camera:

		[code]if(Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { mCamera =;}
		else {	mCamera =;	}[/code]

Although it has the same logic as code piece listed in the book, it worked for me. Both front and rear cameras worked fine.

Then for the sake of experiment I switched back to authors’ code and it worked as well. Bug?

Hope it helps.