Android Question SetScreenOrientation & Layout with larger phone screens

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

In my app I am detecting if the user is using a phone or a tablet and then showing a different layout based on what device they are using.

I am detecting the screen size and showing the layout like the following:

B4X:
If GetDeviceLayoutValues.ApproximateScreenSize > 6 Then
    phone1.SetScreenOrientation(0)
    Activity.LoadLayout("landscape")
    Log("** tablet **")
Else
    phone1.SetScreenOrientation(1)
    Activity.LoadLayout("portrait")
    Log("** phone **")
End If

This has been working for some time, but now I have a customer using an OnePlus 7T phone.

The issue is its rotating to landscape due to the code as above, and it should be using the phone layout.

I think it's because the phone they are using is an 6.55" screen and I am telling my app if it's a 6" plus screen to rotate.

Is there a better way in detecting if the user is using a large screen like a tablet or a small screen like a phone other than the code I am using above ?

I guess the only way is to increase the screen size in my code like the following?

B4X:
If GetDeviceLayoutValues.ApproximateScreenSize >= 7 Then
    phone1.SetScreenOrientation(0)
    Activity.LoadLayout("landscape")
    Log("** tablet **")
Else
    phone1.SetScreenOrientation(1)
    Activity.LoadLayout("portrait")
    Log("** phone **")
End If
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…