As part of my widget, I use an instance of the Camera object.
This is what I want to do. The user will click on my widget, I get an instance of the Camera(if it’s not already stored), use it, then store it. If they click the widget again, I want to use that same instance that I used previously.
Is this possible?
EDITED: I can’t release the Camera(android.hardware.Camera) until the user clicks on the widget the second time. So the user clicks on the widget the first time, I get the camera and hold on to it until they click the widget again.
The problem I am running into is on the second click, I am trying to get the Camera again, which I can’t because I currently have it in use.
Ok, so I figured this out, I think.
If I make a static class object for the widget class, it seems to keep it in memory.
private static Camera camera = null;Then setting it in code..
camera = Camera.open();does seem to keep it in memory for use later. I don’t know if that’s really inefficient or not, but that’s the only way I could get it to work.