Android Question Portrait orientation - Camera Landscape

prajinpraveen

Active Member
Licensed User
Longtime User
Good day,

I have an app that is set to display only in portrait mode. One of the activities has a button that invokes the camera, takes a picture and uploads it to the server.
When the phone is held in portrait, and the camera is used, the app takes the photo in portrait and returns to the calling activity, and resumes the code to upload the photo. All good.


When the phone is held in landscape, it takes the photo, and as soon as "OK" on the camera preview is pressed, because the phone is held in the landscape mode, the activity create and resume is called, which recreates the activity and fails to resume the code to upload the image. I have tried to set the orientation to portrait as soon as the photo is taken, which still doesn't help. Any suggestion will be greatly appreciated.

set phone orientation
** Activity (image) Pause, UserClosed = false **
** Activity (image) Create, isFirst = false **
Creating Image Activity
** Activity (image) Resume **
Resuming Image Activity
** Activity (image) Pause, UserClosed = false **
 

William Lancee

Well-Known Member
Licensed User
Longtime User
At the top of the Activity try setiing in #Region Project Attributes
#SupportedOrientations: unspecified

And then as first line in Actiity_Create add
Dim ph As Phone: ph.SetScreenOrientation(7)

When I tried this, I could set the orientation in code.
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
The orientation is set in MAIN

#SupportedOrientations: portrait

The app is always in portrait mode. when the camera intent is triggered, and the phone is rotated, upon completion of the intent, the calling activity receives focus and thinks that the orientation has changed and triggers the activity create.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
#SupportedOrientations: unspecified in combination with ph.SetScreenOrientation(7)
Puts the app in portrait mode when Activity_Create is invoked.
This when the Activity starts, but also when it is restarted, so always.

If it doesn't work for you, maybe some else has an idea?
 
Upvote 0
Top