KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have classic android app with camera preview (common implem that can be found in many tutorials [marakana etc.]) that is supposed to take picture in a given time interval. Threading and killing threads is done, errors such "method called after release" are handled. But sometimes the well-known error 100 occurs. I accepted the fact that it happens and tried to handle it too. I implemented ErrorCallback and its onError method where the current camera object is released and instantiated a new one as written in official documentation. But (with no surprise) it is not enough. New camera is maybe wrongly allocated because an message "CameraDemo has been exited unexpectedly" appears now. I've read many docs and examples in hope, that a proper proceeding will be somewhere explained but no one has such problem apparently. So I would like to ask what else should I do beside releasing and creating new camera? Here is the code: ErrorCallback CEC = new ErrorCallback() { public void onError(int error, Camera camera) { Log.d("CameraDemo", "camera error detected"); if(error == Camera.CAMERA_ERROR_SERVER_DIED) { Log.d("CameraDemo", "attempting to reinstantiate new camera"); camera.stopPreview(); camera.setPreviewCallback(null); camera.release(); //written in documentation... camera = null; camera = Camera.open(); } } }; Shortly - if I release and recreate camera in onError callback then RuntimeException Method called after release (takePicture) is raised. So should I somehow assign the surface holder to camera again or recreate the surface holder too? It would be enough to direct me e.g. to some forums, where it is described or solved, etc. Thanks for any help.
Tags (comma-separated)
Save Edits
Cancel