Android Question Different Orientation on other activity

adjie

Member
Licensed User
Longtime 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
Longtime User
Use the phone library to set the screen orientation
 
Upvote 0

adjie

Member
Licensed User
Longtime 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.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

RandomCoder

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

adjie

Member
Licensed User
Longtime 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.
 
Upvote 0
Top