Android Question Determine if the device is a smartphone or tablet

D

Deleted member 103

Guest
Hi,

With this code, you can determine whether the device is a smartphone or tablet.
I have tablet with a resolution of 800x480, but is not recognized as a tablet, Why?

B4X:
Sub GetDevicePhysicalSize As Float
    Dim lv As LayoutValues
    lv = GetDeviceLayoutValues
    Return Sqrt(Power(lv.Height / lv.Scale / 160, 2) + Power(lv.Width / lv.Scale / 160, 2))
End Sub

Sub IsTablet As Boolean
    If GetDevicePhysicalSize > 6 Then
        '7'' or 10'' tablet
        Return True
    Else
        'phone
        Return False
    End If
End Sub
 

NJDude

Expert
Licensed User
Longtime User
There are just a few tablets with telephony capabilities, if you need to determine if the device is a phone or tablet you will have to combine your queries, check for "small" screen, then "large" screen WITHOUT telephony and then "large" screen WITH telephony, note that you might get some false positives, especially from "clone" tablets.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
How do you do that: "...large" screen WITHOUT telephony and then "large" screen WITH telephony... ??
Using screen sizes is not good practice, considering that 7 inch tablets with phone capabilities are now coming to market!
Check the attached sample, that's one way to find out.
 

Attachments

  • PhoneTabletTest_Sample.zip
    9.4 KB · Views: 326
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
So if you know of a better way than using the screensize to determine if the Android is a tablet or a smartphone, then please let us know.
I still don't understand how do you define a tablet. As I see it a tablet is a device larger than 6 inch. It is not related whether it has 3g or not.

There are many tablets with 3g (including the first Motorola Xoom - 10'').
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
A tablet is anything bigger than 6 inches. (And "phablets" are blurring that line)
I have 2, 7 inch tablets with a "permanent" data connection (Galaxy Tab and Nexus 7)
If you're using this simply to detect if there is a data connection or not, you're going about it the wrong way.
 
Upvote 0
Top