2 Replies - 845 Views - Last Post: 26 July 2013 - 07:40 PM

#1 GaryDoo  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 125
  • Joined: 10-February 13

Android Camera Preview setDisplayOrientation fail

Posted 26 July 2013 - 04:34 AM

Hi,

I have a camera preview as part of an application I am developing, the preview is in landscape, so I call
camera.setDisplayOrientation(90);
in the
 onresume() 
method to set the preview to portrait (requirement). I give the user an option to retake the image, so when they go back again, it calls the
onresume()
again. I have tested this on the nexus10 and there are no problems, however, when running it on a device running froyo 2.2, it's a htc handset, the app crashes and I get this

07-26 12:19:43.389: E/AndroidRuntime(2245): FATAL EXCEPTION: main
07-26 12:19:43.389: E/AndroidRuntime(2245): java.lang.RuntimeException: set display orientation failed
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.hardware.Camera.setDisplayOrientation(Native Method)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at com.purple.reepfragment.SnapFragment.onresume(SnapFragment.java:114)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.Fragment.performResume(Fragment.java:1503)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.os.Handler.handleCallback(Handler.java:587)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.os.Looper.loop(Looper.java:144)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at android.app.ActivityThread.main(ActivityThread.java:4937)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-26 12:19:43.389: E/AndroidRuntime(2245): 	at dalvik.system.NativeStart.main(Native Method)



EDIT====
So just to be clear, the application runs through camera.setdisplayorientation(90); the first time no problem, take the pic, display it and then if the user clicks retake, it goes as far as that line and crashes...

I really am struggling to figure out what the problem is as
setDisplayOrientation
is supported in Froyo...
Would anyone have any ideas or have come across this before??

This post has been edited by GaryDoo: 26 July 2013 - 04:42 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Android Camera Preview setDisplayOrientation fail

#2 GaryDoo  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 125
  • Joined: 10-February 13

Re: Android Camera Preview setDisplayOrientation fail

Posted 26 July 2013 - 05:34 AM

I managed to sort this myself...thankfully after a lot of banging my head against the wall
Was This Post Helpful? 0
  • +
  • -

#3 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,423
  • Joined: 29-July 11

Re: Android Camera Preview setDisplayOrientation fail

Posted 26 July 2013 - 07:40 PM

Let me guess. You were trying to change the orientation while the surfaceholder was active?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1