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
 
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
can you be more specific? where are you denying screen rotation landscape right and allowing portrait and landscape left?
 
Upvote 0
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
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
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
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.
so how to allow only portrait and landscape left? :/
 
Upvote 0
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
You did read my answer? Set a NEW one if the wrong one is set

so i can set more than one orientation?
 
Upvote 0
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
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.
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
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: Copy
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
Back
Top