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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en