Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to detect tablet devices
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
carlo  
View profile  
 More options Feb 16 2011, 10:51 am
From: carlo <sazi...@gmail.com>
Date: Wed, 16 Feb 2011 07:51:30 -0800 (PST)
Local: Wed, Feb 16 2011 10:51 am
Subject: How to detect tablet devices
The question is simple... is there a (simple) way to detect if the
current device, on which my application is running, is a tablet?
I know I could rely on the screen resolution, but I was wondering if
there is a more deterministic way...

Thanks in advance
Carlo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
carlo  
View profile  
 More options Feb 16 2011, 6:07 am
From: carlo <sazi...@gmail.com>
Date: Wed, 16 Feb 2011 03:07:51 -0800 (PST)
Local: Wed, Feb 16 2011 6:07 am
Subject: How to detect tablet devices
The question is simple... is there a (simple) way to detect if the
current device, on which my application is running, is a tablet?
I know I could rely on the screen resolution, but I was wondering if
there is a more deterministic way...

Thanks in advance
Carlo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Feb 16 2011, 3:54 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Wed, 16 Feb 2011 15:54:32 -0500
Local: Wed, Feb 16 2011 3:54 pm
Subject: Re: [android-developers] How to detect tablet devices

On Wed, Feb 16, 2011 at 6:07 AM, carlo <sazi...@gmail.com> wrote:
> The question is simple... is there a (simple) way to detect if the
> current device, on which my application is running, is a tablet?
> I know I could rely on the screen resolution, but I was wondering if
> there is a more deterministic way...

What defines a tablet other than screen resolution and density?

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rich friedel  
View profile  
 More options Feb 16 2011, 4:01 pm
From: rich friedel <rich.frie...@gmail.com>
Date: Wed, 16 Feb 2011 13:01:57 -0800 (PST)
Local: Wed, Feb 16 2011 4:01 pm
Subject: Re: [android-developers] How to detect tablet devices

telephony... however at the pace things are moving that might be an obsolete test soon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
String  
View profile  
 More options Feb 16 2011, 5:27 pm
From: String <sterling.ud...@googlemail.com>
Date: Wed, 16 Feb 2011 14:27:52 -0800 (PST)
Local: Wed, Feb 16 2011 5:27 pm
Subject: Re: How to detect tablet devices

As a first approximation, if the device vendor has chosen to go with large
(or xlarge) screen size, then it's a tablet. I know, other devices (like
netbooks and Google TV) will also get picked up by this, but that's why I
called it a first approximation.

To detect this in code, take a look at this blog post:
http://blog.alsutton.com/2010/12/07/android-tablet-phone-uis-in-one-a...
.

String


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dianne Hackborn  
View profile  
 More options Feb 16 2011, 8:24 pm
From: Dianne Hackborn <hack...@android.com>
Date: Wed, 16 Feb 2011 17:24:27 -0800
Local: Wed, Feb 16 2011 8:24 pm
Subject: Re: [android-developers] Re: How to detect tablet devices

In fact, you really shouldn't think "target a tablet."  What does "tablet"
mean?  You will quickly find that this is an incredibly nebulous term.

Target screen size: adjust your UI for xlarge (or large).

Target other specific hardware aspects that make sense for you (does it have
a hardware keyboard?  Phone radio?  Etc).

On Wed, Feb 16, 2011 at 2:27 PM, String <sterling.ud...@googlemail.com>wrote:

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SteveHM  
View profile  
 More options Feb 16 2011, 4:15 pm
From: SteveHM <merr...@googlemail.com>
Date: Wed, 16 Feb 2011 13:15:29 -0800 (PST)
Local: Wed, Feb 16 2011 4:15 pm
Subject: Re: How to detect tablet devices
Wrong.  My legit. european version of the Galaxy Tab has full
telephony/GPRS alongside WiFi etc.

On Feb 16, 9:01 pm, rich friedel <rich.frie...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rich friedel  
View profile  
 More options Feb 18 2011, 3:07 pm
From: rich friedel <rich.frie...@gmail.com>
Date: Fri, 18 Feb 2011 15:07:54 -0500
Local: Fri, Feb 18 2011 3:07 pm
Subject: Re: [android-developers] Re: How to detect tablet devices

that was posted days ago but sat in moderation and shortly thereafter I
found out I was incorrect but couldn't take it back... whoops!
On Feb 18, 2011 2:49 PM, "SteveHM" <merr...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
carlo  
View profile  
 More options Feb 21 2011, 9:09 am
From: carlo <sazi...@gmail.com>
Date: Mon, 21 Feb 2011 06:09:25 -0800 (PST)
Local: Mon, Feb 21 2011 9:09 am
Subject: Re: How to detect tablet devices
Thank you all

Here is the code I use for my app:

public boolean isTablet() {
    try {
        // Compute screen size
        DisplayMetrics dm =
context.getResources().getDisplayMetrics();
        float screenWidth  = dm.widthPixels / dm.xdpi;
        float screenHeight = dm.heightPixels / dm.ydpi;
        double size = Math.sqrt(Math.pow(screenWidth, 2) +
                                Math.pow(screenHeight, 2));
        // Tablet devices should have a screen size greater than 6
inches
        return size >= 6;
    } catch(Throwable t) {
        Log.error(TAG_LOG, "Failed to compute screen size", t);
        return false;
    }

}

Any comments/suggestions?

On 16 Feb, 12:07, carlo <sazi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TreKing  
View profile  
 More options Feb 23 2011, 11:00 am
From: TreKing <treking...@gmail.com>
Date: Wed, 23 Feb 2011 10:00:54 -0600
Local: Wed, Feb 23 2011 11:00 am
Subject: Re: [android-developers] Re: How to detect tablet devices

On Mon, Feb 21, 2011 at 8:09 AM, carlo <sazi...@gmail.com> wrote:
> Any comments/suggestions?

Read Dianne's post.

--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dianne Hackborn  
View profile  
 More options Feb 23 2011, 12:27 pm
From: Dianne Hackborn <hack...@android.com>
Date: Wed, 23 Feb 2011 09:27:13 -0800
Local: Wed, Feb 23 2011 12:27 pm
Subject: Re: [android-developers] Re: How to detect tablet devices

No no no no no.

getResources().getConfiguration() tells you this kind of stuff about the
device.

Look for LARGE or XLARGE screen size, depending on what you want to do.

And of course you can have your resources adjust automatically by using
things like layout-xlarge.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Davies  
View profile  
 More options Feb 23 2011, 5:28 pm
From: Scott Davies <code-p...@hotmail.com>
Date: Wed, 23 Feb 2011 17:28:39 -0500
Local: Wed, Feb 23 2011 5:28 pm
Subject: Re: [android-developers] Re: How to detect tablet devices

Dianne, I'm confused.

If your response had six "no's", I'd know not to do this for sureŠbut with
just five ?

This appears to be a grey issueŠ :)

- Scott

From:  Dianne Hackborn <hack...@android.com>
Reply-To:  <android-developers@googlegroups.com>
Date:  Wed, 23 Feb 2011 09:27:13 -0800
To:  <android-developers@googlegroups.com>
Cc:  carlo <sazi...@gmail.com>
Subject:  Re: [android-developers] Re: How to detect tablet devices

No no no no no.

getResources().getConfiguration() tells you this kind of stuff about the
device.

Look for LARGE or XLARGE screen size, depending on what you want to do.

And of course you can have your resources adjust automatically by using
things like layout-xlarge.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlo Codega  
View profile  
 More options Feb 23 2011, 12:47 pm
From: Carlo Codega <sazi...@gmail.com>
Date: Wed, 23 Feb 2011 18:47:36 +0100
Local: Wed, Feb 23 2011 12:47 pm
Subject: Re: [android-developers] Re: How to detect tablet devices

Is there any numeric size about XLARGE screens? AFAIK there could be
smartphone devices with "xlarge" screens, or not? I don't see any
documentation which says that XLARGE screens are > 6 inches

Does xlarge refer to the phisical size? or resolution?

Carlo

On Wed, Feb 23, 2011 at 6:27 PM, Dianne Hackborn <hack...@android.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile   Translate to Translated (View Original)
 More options Feb 25 2011, 8:36 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Fri, 25 Feb 2011 08:36:25 -0500
Local: Fri, Feb 25 2011 8:36 am
Subject: Re: [android-developers] Re: How to detect tablet devices

On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega <sazi...@gmail.com> wrote:
> Is there any numeric size about XLARGE screens? AFAIK there could be
> smartphone devices with "xlarge" screens, or not? I don't see any
> documentation which says that XLARGE screens are > 6 inches

> Does xlarge refer to the phisical size? or resolution?

Neither, though physical size is more relevant.

Screen size, in terms of small/normal/large/xlarge, will be determined
by device manufacturers based upon physical screen size and the
distance that screen will be from the user. A phone is held closer to
the user's eyes than is a tablet, and both are held closer to the
user's eyes than is an LCD TV.

At best, Google might come up with a size guideline per form factor --
10" tablets are xlarge, for example. However, in the end, the device
manufacturer will choose the value for the device. How the device
manufacturer makes that choice, AFAIK, is up to the device
manufacturer.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ole!  
View profile  
 More options Mar 28 2011, 12:38 pm
From: "ole!" <olub...@gmail.com>
Date: Mon, 28 Mar 2011 09:38:34 -0700 (PDT)
Local: Mon, Mar 28 2011 12:38 pm
Subject: Re: How to detect tablet devices
This thread has focused on the tablet screen as a distinguisher.
Another real problem is that tablets from a specific carrier (such as
the T-Mobile Galaxy), cannot make a phone call.
I have found no way to distinguish this characteristic of tablets.

What I have tried:
1. catching an exception from start_activity using the ACTION_CALL
intent ( no exception)
2. TelephonyManager.getPhoneType() returns a valid state (GSM)
3. TelephonyManager.getCallState() return a valid state (IDLE)

Any ideas?

Olaf Lubeck

On Feb 25, 7:36 am, Mark Murphy <mmur...@commonsware.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron  
View profile  
 More options Oct 24 2012, 3:31 pm
From: Aaron <aobrien...@gmail.com>
Date: Wed, 24 Oct 2012 12:31:20 -0700 (PDT)
Local: Wed, Oct 24 2012 3:31 pm
Subject: Re: How to detect tablet devices

I know this is an old thread but in case someone stumbles across this in
the future the best way (for me at least) to solve this was to get the
metrics of the screen size (width and height in pixels) calculate the
hypotenuse then divide by the dpi.  In theory this gives you the dimension
in inches of the screen size.

With that you can make the decision about what tablet means to you and then
you can make decisions appropriately, here is a code snippet:

        DisplayMetrics metrics = new DisplayMetrics();

        getWindowManager().getDefaultDisplay().getMetrics(metrics);

        double inches = Math.sqrt((metrics.widthPixels * metrics.widthPixels)
+ (metrics.heightPixels * metrics.heightPixels)) / metrics.densityDpi;

        if (inches > TABLET_SIZE)

        {

        this.setRequestedOrientation(ActivityInfo.
SCREEN_ORIENTATION_LANDSCAPE);

        }
And here are some of stats you get:
Samsung Nexus: 10-23 20:54:16.598: D/Enter(14861): Width: 1196 Height: 720
DPI: 320 Density: 2.0
Droid: 10-24 07:12:42.436: D/Enter(1823):  Width: 854  Height: 480 DPI: 240
Density: 1.5
Nexus 7: 10-23 20:55:06.405: D/Enter(15663): Width: 1280 Height: 736 DPI:
213 Density: 1.33125
Samsung 10.1 10-23 21:10:49.180: D/Enter(3263):  Width: 1280 Height: 752
DPI: 160 Density: 1.0

These equate to the following:
Galaxy Nexus = 4.3
Droid = 4.08
Nexus 7 = 6.9
Samsug 10.1 = 9.2

Based on this information I decided if a device was over 6 inches I would
lock the rotation to landscape forcing a specific layout (of course you
still have to make sure you are picking up the correct layout resources).

It is an imperfect solution but there is such a variance between devices
and manufacturers there really isn't a perfect solution.

-Aaron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
djhacktor  
View profile  
 More options Oct 25 2012, 8:32 am
From: djhacktor <deepanshcri...@gmail.com>
Date: Thu, 25 Oct 2012 05:32:38 -0700 (PDT)
Local: Thurs, Oct 25 2012 8:32 am
Subject: Re: How to detect tablet devices

public static boolean isTablet(Context paramContext)
  {
    if
(((TelephonyManager)paramContext.getSystemService("phone")).getPhoneType()
== 0);
    for (boolean bool = true; ; bool = false)
      return bool;
  }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Oct 25 2012, 3:50 pm
From: Lew <lewbl...@gmail.com>
Date: Thu, 25 Oct 2012 12:50:58 -0700 (PDT)
Local: Thurs, Oct 25 2012 3:50 pm
Subject: Re: How to detect tablet devices

djhacktor wrote:
> public static boolean isTablet(Context paramContext)
>   {
>     if
> (((TelephonyManager)paramContext.getSystemService("phone")).getPhoneType()
> == 0);
>     for (boolean bool = true; ; bool = false)
>       return bool;
>   }

WTF?

This is humor, right?

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bob  
View profile  
 More options Oct 25 2012, 5:10 pm
From: bob <b...@coolfone.comze.com>
Date: Thu, 25 Oct 2012 14:10:30 -0700 (PDT)
Local: Thurs, Oct 25 2012 5:10 pm
Subject: Re: How to detect tablet devices

It's either humor or tumor.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »