开发者

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

开发者 https://www.devze.com 2023-01-11 10:43 出处:网络
Android 2.1 - I\'m trying to wo开发者_JAVA百科rk 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

Android 2.1 - I'm trying to wo开发者_JAVA百科rk 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消