How can we block the orientation of the camera screen during the camera capture process?

Our camera takes about 10-15 seconds (due to the user equipment of the camera). I need 10-15 seconds during this process, I would not want the user to change the screen orientation.

I placed the takepicture call in the doInBackground of the Async task.

In the onPreExecute () method, I placed

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

And in onPostExecute I posted

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

This solution does not work for me and causes the camera and device to crash, and I had to reboot the device.

+5
source share
1 answer

Have you tried blocking orientation from AndroidManifest? adding the bottom line to your camera activity

<activity android:label="@string/activity_name" android:screenOrientation="portrait" />

or

<activity android:label="@string/activity_name" android:screenOrientation="landscape" />
+2
source

All Articles