Android Question Different Orientation on other activity

adjie

Member
Licensed User
On the main activity I set the #SupportedOrientations: portrait, but I need to enable rotation on another activities. How to do that ? I tried to copy that setting to the activity, but it said "attribute not supported". Please help, thanks.
 

barx

Well-Known Member
Licensed User
Use the phone library to set the screen orientation
 

adjie

Member
Licensed User
Great barx ! How could I'm not remembered that.
code below (in case beginners like me need it ;) ) :

B4X:
Sub Globals
    Dim ph as phone
End Sub

Sub Activity_Create(FirstTime As Boolean)   
    Activity.LoadLayout("1")
    ph.SetScreenOrientation(-1) ' -1 for unspesified, 0 for landscape and 1 for portrait
End Sub
It will allow only modified activity to freely rotate, where as the other remains as main activity setting.
 

NJDude

Expert
Licensed User
You can also add the line below to your manifest, that way you don't add overhead to your code like the phone library.
B4X:
SetActivityAttribute(<ACTIVITY_NAME>, android:screenOrientation, "unspecified")
 

RandomCoder

Well-Known Member
Licensed User
I wish I knew more about the options for the manifest file. Do you have a good resource? Care to share the link with us? :D
 

RandomCoder

Well-Known Member
Licensed User
Thanks Manfred, link added to my favourite's.
 

adjie

Member
Licensed User
You can also add the line below to your manifest, that way you don't add overhead to your code like the phone library.
B4X:
SetActivityAttribute(<ACTIVITY_NAME>, android:screenOrientation, "unspecified")
Thanks NJDude, I'm switch to your code now.
 
Top