-
10 Oct 2012 5:56 AM #1
Unanswered: How Ext.os.deviceType works.
Unanswered: How Ext.os.deviceType works.
I was under the impression that Ext.os.deviceType works based on userAgent.
I have changed userAgent in chrome from the settings option to that of android, till i'm getting deviceType as "Desktop" i was expecting something like "Phone"? I'm i missing something so simple which i'm yet to identify ?
useragent.jpg
-
12 Oct 2012 6:19 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
There are a few things that can affect this, here is the code that determines the type (in Ext.env.OS):
Code:var search = window.location.search.match(/deviceType=(Tablet|Phone)/), nativeDeviceType = window.deviceType; // Override deviceType by adding a get variable of deviceType. NEEDED FOR DOCS APP. // E.g: example/kitchen-sink.html?deviceType=Phone if (search && search[1]) { deviceType = search[1]; } else if (nativeDeviceType === 'iPhone') { deviceType = 'Phone'; } else if (nativeDeviceType === 'iPad') { deviceType = 'Tablet'; } else { if (!osEnv.is.Android && !osEnv.is.iOS && /Windows|Linux|MacOS/.test(osName)) { deviceType = 'Desktop'; // always set it to false when you are on a desktop Ext.browser.is.WebView = false; } else if (osEnv.is.iPad || osEnv.is.Android3 || (osEnv.is.Android4 && userAgent.search(/mobile/i) == -1)) { deviceType = 'Tablet'; } else { deviceType = 'Phone'; } }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Oct 2012 10:45 AM #3
I had a look into those,
For this
http://docs.sencha.com/touch/2-0/touch-build/examples/production/list/index.html
I have changed the userAgent to that of android and tried
which return undefined.Code:var search = window.location.search.match(/deviceType=(Tablet|Phone)/), nativeDeviceType = window.deviceType;


Reply With Quote