Android Question Landscape both 90o and 270o without Portrait?

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Anybody knows how to define Orientation ONLY IN LANDSCAPE but in 90o and 270o without portrait orientation?

I need the screens works only in Orientation 0 and 2

Like this:


onlylandscape.jpg
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Not working! I understand for ONLY landscape mode (reverse or no) maybe this:

B4X:
Dim ph As Phone
ph.SetScreenOrientation(0) 'Landscape
ph.SetScreenOrientation(8) 'reverseLandscape

Landscape: https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE
Reverse Landscape: https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_REVERSE_LANDSCAPE

But I tried in here and not working!

and of course:
#SupportedOrientations: unspecified
 
Upvote 0
D

Deleted member 103

Guest
In my app, the rotation is not automatic, it is defined only by the setting.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I "found" this strange behavior.

Normaly, if you don't specify the orientation, when you rotate the device, Activity_Create and then Activity_Resume will raise.
If you set the orientation using SetScreenOrientation, the Activity will no more recreated.
 

Attachments

  • ReverseOrientation.zip
    9.2 KB · Views: 190
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
ahh ok. I need something automatic.
try changing manifest

this will set the activity video to be landscape only. do this for any activity you want to predefine....

B4X:
SetActivityAttribute(video, android:screenOrientation, "landscape")
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
I "found" this strange behavior.

Normaly, if you don't specify the orientation, when you rotate the device, Activity_Create and then Activity_Resume will raise.
If you set the orientation using SetScreenOrientation, the Activity will no more recreated.

It´s only save the last orientation for next time you start your app
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
try changing manifest

this will set the activity video to be landscape only. do this for any activity you want to predefine....

B4X:
SetActivityAttribute(video, android:screenOrientation, "landscape")

Hey DonManfred,

Not work, it´s the same like this:

ph.SetScreenOrientation(0)

or

#SupportedOrientations: landscape
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You should set the application orientation as Unspecified and then in a "orientation changed" event use SetScreenOrientation, according to a previous Landscape orientation saved in a file.
However, as far as I know, the only way to know if the device has been rotated is to compare the size of the Activity in Activity_Create ot Activity_Resume and these events do not raise if you use SetScreenOrientation.

I know that this is not a helpful answer, it is an observation.
 
Upvote 0
Top