Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we lock the camera screen orientation during the camera capture process?

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.

like image 400
Velivala Avatar asked Nov 03 '22 02:11

Velivala


1 Answers

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" />
like image 196
MehrozKarim Avatar answered Nov 15 '22 00:11

MehrozKarim