[android-developers] Re: How to detect tablet devices

2012-10-24 Thread Aaron
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

On Monday, March 28, 2011 11:38:34 AM UTC-5, ole! wrote:
>
> 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  wrote: 
> > On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega  
> 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/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>  
> > 
> > _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 
> > Available!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect tablet devices

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

On Thursday, 25 October 2012 01:01:21 UTC+5:30, Aaron wrote:
>
> 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
>
> On Monday, March 28, 2011 11:38:34 AM UTC-5, ole! wrote:
>>
>> 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  wrote: 
>> > On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega  
>> 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/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>>  
>> > 
>> > _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 
>> > Available!
>
>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect tablet devices

2012-10-25 Thread Lew
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 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect tablet devices

2012-10-25 Thread bob
 

It's either humor or tumor.

On Thursday, October 25, 2012 2:50:59 PM UTC-5, Lew wrote:
>
> 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 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect tablet devices

2011-02-16 Thread String
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-apk-how-to/
. 

String

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: How to detect tablet devices

2011-02-18 Thread SteveHM
Wrong.  My legit. european version of the Galaxy Tab has full
telephony/GPRS alongside WiFi etc.

On Feb 16, 9:01 pm, rich friedel  wrote:
> telephony... however at the pace things are moving that might be an obsolete 
> test soon

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect tablet devices

2011-02-22 Thread carlo
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  wrote:
> The question is simple... is there a (simple) way todetectif the
> current device, on which my application is running, is atablet?
> 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 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to detect tablet devices

2011-03-28 Thread ole!
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  wrote:
> On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega  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/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
> Available!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to detect tablet devices

2011-02-16 Thread Dianne Hackborn
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 wrote:

> 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-apk-how-to/
> .
>
> String
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-18 Thread rich friedel
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"  wrote:
> Wrong. My legit. european version of the Galaxy Tab has full
> telephony/GPRS alongside WiFi etc.
>
> On Feb 16, 9:01 pm, rich friedel  wrote:
>> telephony... however at the pace things are moving that might be an
obsolete test soon
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-23 Thread TreKing
On Mon, Feb 21, 2011 at 8:09 AM, carlo  wrote:

> Any comments/suggestions?


Read Dianne's post.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-23 Thread Dianne Hackborn
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.

On Mon, Feb 21, 2011 at 6:09 AM, carlo  wrote:

> 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  wrote:
> > The question is simple... is there a (simple) way todetectif the
> > current device, on which my application is running, is atablet?
> > 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 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-23 Thread Scott Davies
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 
Reply-To:  
Date:  Wed, 23 Feb 2011 09:27:13 -0800
To:  
Cc:  carlo 
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.

On Mon, Feb 21, 2011 at 6:09 AM, carlo  wrote:
> 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  wrote:
>> > The question is simple... is there a (simple) way todetectif the
>> > current device, on which my application is running, is atablet?
>> > 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 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+unsubscr...@googlegroups.com
> <mailto:android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-24 Thread Carlo Codega
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 wrote:

> 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.
>
> On Mon, Feb 21, 2011 at 6:09 AM, carlo  wrote:
>
>> 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  wrote:
>> > The question is simple... is there a (simple) way todetectif the
>> > current device, on which my application is running, is atablet?
>> > 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 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+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>
>
> --
> 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to detect tablet devices

2011-02-25 Thread Mark Murphy
On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega  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 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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en