Determine If the Device Is a Smartphone or Tablet

Determine if the device is a smartphone or tablet?

This subject is discussed in the Android Training:

Use the Smallest-width Qualifier

If you read the entire topic, they explain how to set a boolean value in a specific value file (as res/values-sw600dp/attrs.xml):

<resources>
<bool name="isTablet">true</bool>
</resources>

Because the sw600dp qualifier is only valid for platforms above android 3.2. If you want to make sure this technique works on all platforms (before 3.2), create the same file in res/values-xlarge folder:

<resources>
<bool name="isTablet">true</bool>
</resources>

Then, in the "standard" value file (as res/values/attrs.xml), you set the boolean to false:

<resources>
<bool name="isTablet">false</bool>
</resources>

Then in you activity, you can get this value and check if you are running in a tablet size device:

boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
if (tabletSize) {
// do something
} else {
// do something else
}

Can we check the device to be smartphone or tablet in Flutter?

Despite iOS has a clear separation between phone and tablet, this doesn't happen in Android. You need to base the choice based on screen width.

Check this article to see an example on how to discriminate: https://flutter.rocks/2018/01/28/implementing-adaptive-master-detail-layouts/

How to detect device is Android phone or Android tablet?

You can also try this

Add boolean parameter in resource file.

in res/values/dimen.xml file add this line

<bool name="isTab">false</bool>

while in res/values-sw600dp/dimen.xml file add this line:

<bool name="isTab">true</bool>

then in your java file get this value:

if(getResources().getBoolean(R.bool.isTab)) {
System.out.println("tablet");
} else {
System.out.println("mobile");
}

REACT NATIVE : There is way to identify a device type (smartphone, tablet, laptop)?

According to API DOC you can use these APIs to detect the device types:

  • getDeviceType
  • isTablet
  • isEmulator
  • getModel

There are so many APIs to get the device name or any other use-cases. Read the API doc :) Also you cannot detect the laptop as far as I know, React Native does not for on PC.

Reliable way to check if the device is a phone, tablet, or set-top box

Basically, what the manufacturer calls it.

You will need to make a list of every device manufacturer and contact them, asking them to declare for each of their device models whether it is a phone, tablet, etc.. You can then build a database that maps something like Build.PRODUCT to the manufacturer's declaration, and use that database to make the determination whether any given device is a phone, tablet, etc.

There is nothing in Android where a manufacturer declares whether the device is a mobile phone, tablet, set-top box, in-car navigation system, in-car entertainment system, watch, television, seat-back entertainment system (for airplanes), desktop phone, etc.

Detecting whether Android device is a phone or a tablet with javascript

You should probably use this sugestion made by google by reading the user agent. If the UA has the word mobile it's a phone, if it doesn't it's a tablet

http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html



Related Topics



Leave a reply



Submit