5

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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Velivala
  • 53
  • 4
  • This link seems relevant: http://stackoverflow.com/questions/2366706/how-to-lock-orientation-during-runtime – AnxGotta Mar 19 '13 at 14:35
  • @AnxGotta The above solution doesnt work for me in Tablets but works great in Phones. – Velivala Mar 22 '13 at 15:19
  • 1
    IF it crashes.. posting the stacktrace would help explain the issue. It will likely be a problem with something you're doing. – JoxTraex Mar 23 '13 at 01:22

1 Answers1

2

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" />
MehrozKarim
  • 170
  • 1
  • 8