I have put together a small camera app but have got a problem.
When I resume my app and call onResume()
I have to reinitialize everything (that is, reopen the camera and create a surfaceview that serves as a camera preview).
Now, my onResume()
looks like this:
@Override
public void onResume() {
super.onResume();
openCamera();
startCameraPreview();
}
The problem is that the methods in onResume()
, namely openCamera()
and startCameraPreview()
, take a lot of time to finish. And therefore my app takes a lot longer to open up which is not a very nice user experience.
The question is: How can I fix this problem? I already tried using AsyncTask
but there I ran into the issue of trying to update the UI from a thread other than the main thread.
Any ideas?