I am planning on using the onPreviewFrame callback to capture raw camera preview frames. Before implementing the actual functionality I ran a simple test where I just print something to the log from that callback function. When I exit from the app using phone’s exit button (I believe this is just a sleep/pause in Android) it looks like the callback is still being called – I keep getting messages in the log. Then the next time I try to run the app I get an exception and when I try another time it works again (so it works every second time). What is the correct way to handle that callback?
I am planning on using the onPreviewFrame callback to capture raw camera preview frames.
Share
Remove callback and release camera in onPause():
You probably get an exception when starting your application every other time because camera is not released and canot be opened.