Issue
In the Android documentation on creating a custom camera Activity (http://developer.android.com/guide/topics/media/camera.html#custom-camera) they get an instance of the Camera in onCreate() and release it in onPause().
Is this correct? Isn't it possible for the Activity to skip onCreate() and spin back up from the onResume() event after a pause? i.e. shouldn't I be getting my reference to the Camera in onResume() as well and have some sort of setCamera() method in the CameraPreview/SurfaceView class?
I'm just getting started with Android development, so maybe I'm missing something here... but the life cycle I'm looking at is located here: http://developer.android.com/reference/android/app/Activity.html
Solution
Is this correct?
It does not look correct.
shouldn't I be getting my reference to the Camera in onResume() as well
I would skip the "as well" part and simply obtain the Camera instance in onResume().
IOW, you want parallelism:
If you clean it up in
onPause(), set it up inonResume()If you clean it up on
onStop(), set it up inonStart()(or possibly the combination ofonCreate()andonRestart()If you clean it up in
onDestroy(), set it up inonCreate()
In the case of a Camera, you do not want to hold onto it when you are not in the foreground, as other apps cannot access it while you have it, so I would go for the onResume()/onPause() pairing.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.