PDA

View Full Version : Ext.is.AndroidTablet



realjax
29 Jun 2011, 1:20 PM
Add this after loading Sencha Touch:



Ext.is.platforms.push({
property: 'userAgent',
regex: /(?=.*android)(?=.*mobile)/i,
identity: 'AndroidPhone'
},
{
property: 'userAgent',
regex: /playbook/i,
identity: 'Playbook'
});

Ext.is.init();
Ext.is.AndroidTablet = Ext.is.Android && (!Ext.is.AndroidPhone);
Ext.is.Tablet = Ext.is.iPad ||(Ext.is.Android && !Ext.is.AndroidPhone) || Ext.is.Playbook;

If it is a well behaving tablet and the manufacturer listened to Googles advice re the userAgent string this works well (It'll probably not work on the cheap chinese 2.x tablets)
Ext.is.Tablet will return true for Ipads,Android and Playbook tablets. Ext.is.AndroidTablet will return true only for Android tablets.
Ext.is.Playbook will return true for Playbooks.