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 <[email protected]> wrote:
>> > On Wed, Feb 23, 2011 at 12:47 PM, Carlo Codega <[email protected]>
>> 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 [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