PDA

View Full Version : Why Android Tablets are considered as Phone?



chandramuralis
4 May 2011, 5:33 AM
I ran my sencha touch application in Android Galaxy and Motorola Xoom, both of them where treated as Phone form factor. When I checked the Support.js class I found that Sencha touch considers a device as a tablet only if it is an iPad. How to determine Android tablets? I doubt how this will treat Blackberry playbook device.



/**
* @property Tablet True if the browser is running on a tablet (iPad)
*/
this.Tablet = this.iPad;
/**
* @property Phone True if the browser is running on a phone.
* @type {Boolean}
*/
this.Phone = !this.Desktop && !this.Tablet;

realjax
4 May 2011, 11:56 AM
How to determine Android tablets?


Check the browsers window.navigator object. But I suspect all you'll find is a ref. to it being Android and that this is the exact reason why Touch can't determine it either.
It doesn't really matter either to your app, the app thinking it is running on a phone with a bigger screen is fine I guess. Can't see any problems.

chandramuralis
4 May 2011, 12:41 PM
The issue we have separate layout for our app based on phone and tablet. That is the reason I asked about this. Why Google doesn't separate their platforms? I wonder how others (websites) are determining Android mobile and tablet

realjax
4 May 2011, 12:48 PM
The issue we have separate layout for our app based on phone and tablet.

Then do a resolution check.

Nikkelmann
22 Aug 2011, 6:04 AM
I recently came up with this solution:


if (Ext.is.Android && !Ext.is.Tablet && Ext.is.Phone) { /* Check for Android Tablet */
Ext.is.Tablet = ((navigator || window.navigator).userAgent.toLowerCase().indexOf("mobile") == -1);
Ext.is.Phone = !Ext.is.Tablet;
}

I based this on the fact that most Android phones have "mobile" in the userAgent string.
http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent

Google Android engineers recommends to specifically detect “mobile” in the User-Agent string as well as “android”. Sencha should conform to this.
http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html

Edit: And so should I:

if (Ext.is.Android && !Ext.is.Tablet && Ext.is.Phone) { /* Check for Android Tablet */
Ext.is.Phone = (Ext.userAgent.indexOf("mobile") > -1);
Ext.is.Tablet = !Ext.is.Phone;
}

I chose not to check for the major version number, for example "android 3" since this will change in the future.

cnelissen
23 Sep 2011, 8:42 AM
Thanks for the code, though it can be shortened to just:



if (Ext.is.Android) {
Ext.is.Phone = Ext.userAgent.indexOf('mobile') > -1;
Ext.is.Tablet = !Ext.is.Phone;
}

fairport
9 Jul 2012, 12:39 AM
Fantastic !! - Just what I was looking for . Still works today .

FrankGarcia
6 Apr 2013, 2:05 AM
The issue we have separate layout for our app based on phone and tablets (http://www.robustbuy.com/laptops-tablets-android-tablets-c-551_1107.html). That is the reason I asked about this. Why Google doesn't separate their platforms? I wonder how others (websites) are determining Android mobile and tablet

I think Galaxy tabs are best for phone and other features. Which tablets you prefer? Are there better tablets than Galaxy?