Android Question Deny screen Orientation Landscape Right

Mattiaf

Active Member
Licensed User
Is there a way to deny the app to support the orientation landscape right?
I'm only interested on Portrait and Landscape Left.
Thanks
 

Situ LLC

Active Member
Licensed User
Public darvuewlta As Phone
....

darvuewlta.SetScreenOrientation(9) 'or 1 depending on the orientation you need.

'
' SetOrientation = 1 'Portrait
' SetOrientation = 0 'Landscape
' SetOrientation = 9 'Reverse Portrait
' SetOrientation = 8 'Reverse Landscape

Have a good one
Regards
 
Upvote 0

Mattiaf

Active Member
Licensed User
can you be more specific? where are you denying screen rotation landscape right and allowing portrait and landscape left?
 
Upvote 0

Situ LLC

Active Member
Licensed User
This is the way I use for rotation and it is fixed and does not change, Maybe there is another way but I do not know it
Regards
 
Upvote 0

Mattiaf

Active Member
Licensed User
did you read my question? i need two orientation possibilities, denying landscape right. Your code does not help because i need to deny, not to set
 
Last edited:
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
did you read my question? i need two orientation possibilities, denying landscape right. Your code does not help because i need to deny, not to set
Pray, what is different if user from 'Portrait' mode rotates the mobile Left of Right ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
sorry but how an image could help? I m just asking how to deny landscape right side orientation.....
Set another Orientation if the orientation set is not allowed.

' SetOrientation = 1 'Portrait
' SetOrientation = 0 'Landscape
' SetOrientation = 9 'Reverse Portrait
' SetOrientation = 8 'Reverse Landscape

This are all possibilities. If you want to deny 8 then set 0 if 8 is set instead.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
sorry but how an image could help? I m just asking how to deny landscape right side orientation.....
I think we do not have such option in Android.
But we are here to help you. If you show the the problem in "landscape right side orientation" we may suggest some remedy for it.
 
Upvote 0

Mattiaf

Active Member
Licensed User
so how to allow only portrait and landscape left? :/
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
so how to allow only portrait and landscape left? :/
You did read my answer? Set a NEW one if the wrong one is set

 
Upvote 0

Mattiaf

Active Member
Licensed User
so i can set more than one orientation?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
so i can set more than one orientation?
NO! How should that work? I never saw any android app which shows two different orientations at the same time

As i wrote:
You can check the active Orientation and set another one if the wrong one is set. That´s the only thing i can imagine to prevent a specific orientation.
 
Last edited:
Upvote 0

Mattiaf

Active Member
Licensed User
ok so basically the logic is to check the current phone orientation and if orientation = reverse landscape than set orientation to portrait. Am i wrong?
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
If this is a non-B4XPages App you could use this to advice the user to change orientation.
Since orientation change triggers Activity_Create it will work all the time.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Do While GetOrientation = 3
        xui.MsgboxAsync("Please rotate the device", "Orientation problem")
        Wait For MsgBox_Result (Result As Int)
    Loop
End Sub

Private Sub GetOrientation As Int
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "window", "java.lang.String")
    r.Target = r.RunMethod("getDefaultDisplay")
    Return r.RunMethod("getOrientation")
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…