简体   繁体   中英

What might cause a NullPointerException when running Camera.release()?

Android 2.1 - I'm trying to work with the Camera via a widget.

My widget sets up and calls mCamera = Camera.open();, I can do everything with the camera, but when I go to release the camera via a 2nd widget click, mCamera.release(); throws a NullPointerException.

How much I find out why that is?

Are you sure that mCamera isn't null?

That's the only reason I can imagine why that specific statement would return a NullPointerException

That's exactly what it was. I was inadvertently re-initializing mCamera every time the Service ran. Put it further up stream and now it works wonderfully!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM