Skip to main content
September 23, 2011
Question

How to detect if on "extra large screen" (tablet) or if phone?

  • September 23, 2011
  • 1 reply
  • 1392 views

For example in my Flex Mobile AIR app, if I wanted to change the position of some components or like make a more android tablet like menu. How can i detect if the user is on a tablet so i can do this? Thanks!

just like a simple thing like this:

if(on a tablet)

{

}

else

{

}

I think i remember seeing an article on this...but I can't seem to find it.

This topic has been closed for replies.

1 reply

Inspiring
September 23, 2011

You can't specifically read "tablet", but you can assume one based on values found in the

Capabilities class

such as:

Capabilities.screenDPI

Capabilities.screenResolutionX

Capabilities.screenResolutionY

Note that capabilities.screenDPI might be different than the DPI found in the server string.

Here is a blog post on the subject

http://renaun.com/blog/2011/01/air-capabilities-screendpi-on-devices/

Example on my phone:

Capabilities.screenResolutionY=848

Capabilities.screenDPI=240

assuming its correct and the screen is 240 pixels per inch...

(848/240 = 3.52 inches)

Although this is not 100% accurate to my device, I can guess its a phone rather than a tablet.

A Native extension with Air 3 can probably pull more detail on the device.