Android Question How to lock activity orientation?

stanks

Active Member
Licensed User
Longtime User
Hi

I have activity 1 with project attributes where i can lock orientation. How to lock orientation on activity 2, 3, etc. which are called from main (1) activity?

thanks
 
You can set the orientation of an activity by adding the following:

Code: Copy
Sub Globals
    ' Phone Variable
    Private ph As Phone
End Sub

Code: Copy
Sub Activity_Resume
    ' 1 = Portrait
    ' 2 = Landscape
    ' 9 = Reverse Portrait
    ' 8 = Reverse Landscape
    ph.SetScreenOrientation(1)
End Sub

You will need to add this line of code where you want to release the screen orientation:

Code: Copy
PH.SetScreenOrientation(-1)

Or you can use this function created by Stevel05:

http://www.b4x.com/android/forum/threads/freeze-orientation.41681/
 
Upvote 0
You can set the orientation of an activity by adding the following:

Code: Copy
Sub Globals
    ' Phone Variable
    Private ph As Phone
End Sub

Code: Copy
Sub Activity_Resume
    ' 1 = Portrait
    ' 2 = Landscape
    ' 9 = Reverse Portrait
    ' 8 = Reverse Landscape
    ph.SetScreenOrientation(1)
End Sub

You will need to add this line of code where you want to release the screen orientation:

Code: Copy
PH.SetScreenOrientation(-1)

Or you can use this function created by Stevel05:

http://www.b4x.com/android/forum/threads/freeze-orientation.41681/

There is an error, 0 = Landscape

this is right :

Code: Copy
Sub Activity_Resume
    ' 1 = Portrait
    ' 0 = Landscape
    ' 9 = Reverse Portrait
    ' 8 = Reverse Landscape
    ph.SetScreenOrientation(1)
End Sub
 
Upvote 0
Back
Top