Hi,
Just wondering if I am missing something..
I am trying to rotate the screen only when running on a 7" or above screen (so on phone size screens it should be portrait)
I am using this code:
The problem I have is it works fine when running this on a phone (Nexus 5) however when I run this on my Nexus 7 it rotates the screen (landscape) but then the app disappears but it is running in background. (it just doesn't display the app user interface).
However, If my Nexus 7 is already Landscape before I run my app, it will work fine and the app doesn't disappear.
Is there something I am missing or is there a better way to do this ?
Just wondering if I am missing something..
I am trying to rotate the screen only when running on a 7" or above screen (so on phone size screens it should be portrait)
I am using this code:
B4X:
Sub Globals
Dim phone1 As Phone
End Sub
Sub GetDevicePhysicalSize As Float
Dim lv AsLayoutValues
lv = GetDeviceLayoutValues
Return Sqrt(Power(lv.Height / lv.Scale / 160, 2) + Power(lv.Width / lv.Scale / 160, 2))
End Sub
Sub Activity_Create(FirstTime As Boolean)
If GetDevicePhysicalSize > 6 Then
If GetDevicePhysicalSize >= 8 Then
'10" tablet
Log("10inch")
Activity.LoadLayout("TabletUI")
phone1.SetScreenOrientation(0) ' Rotate to Landscape
End If
If GetDevicePhysicalSize < 8Then
'7" tablet
Log("7inch")
Activity.LoadLayout("TabletUI")
phone1.SetScreenOrientation(0) ' Rotate to Landscape
End If
End If
' less than 6" screen (such as a phone)
If GetDevicePhysicalSize <= 6 Then
'phone
Log("phone")
Activity.LoadLayout("PhoneUI")
End If
End Sub
The problem I have is it works fine when running this on a phone (Nexus 5) however when I run this on my Nexus 7 it rotates the screen (landscape) but then the app disappears but it is running in background. (it just doesn't display the app user interface).
However, If my Nexus 7 is already Landscape before I run my app, it will work fine and the app doesn't disappear.
Is there something I am missing or is there a better way to do this ?