Our camera takepicture takes around 10-15 seconds (due to custom camera hardware). What I need is during this process of 10-15 seconds, I would not want the user to change the screen orientation.

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

In the onPreExecute() method I have placed

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

And in onPostExecute I placed

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

This solution doesn't work for me and causes the camera and device to be crashed and I had to reboot the device.

有帮助吗?

解决方案

Did you try blocking the orientation from the AndroidManifest ? by adding the below line in your camera activity

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

or

<activity android:label="@string/activity_name" android:screenOrientation="landscape" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top