PDA

View Full Version : Ext.device.* problem on android phone



a3366873
7 Oct 2013, 12:37 PM
Hi,

Another problem... I have a simple app like "hello world" and I want to test some features from Ext.device.*
Some works fine on standard web browser (connection, geolocation, device, notification) but when running sencha app -run native with my Samsung Galaxy SII connected via USB only blank screen appears. When I remove device features from code, my app is loading on my phone without problems.
Only geolocation don't crash my app, but no location is shown (web browser shows some location after asking for my permission).
Do anyone knows good step by step tutorial or screencast for using device features in ST 2.3? Docs are lacking detailed description for newbies on how to use it.
But most of all, can anybody help me to launch this on my mobile?

Kurt001
7 Oct 2013, 1:47 PM
Did you add 'Ext.device.*' to the requires in the app.js?

a3366873
7 Oct 2013, 1:57 PM
yes, for geolocation i have:


requires: [
'Ext.device.Geolocation'
]

and it works fine on my desktop but not when built for mobile

Kurt001
8 Oct 2013, 2:09 AM
But you are running Sencha build and not Cordova/PhoneGap 3.0?

a3366873
8 Oct 2013, 12:01 PM
I found what I was missing - it was phonegap stuff. I added plugins with phonegap local plugin add {repository} (from phonegap subdirectory) and updated config.xml with feature tags according to phonegap docs. I tested Device, Compass, Accelerometer, Connection APIs with success.
But I still have issue with geolocation api.

phonegap plugins installed:


$ phonegap local plugin list
[phonegap] org.apache.cordova.device
[phonegap] org.apache.cordova.device-motion
[phonegap] org.apache.cordova.device-orientation
[phonegap] org.apache.cordova.geolocation
[phonegap] org.apache.cordova.network-information


in config.xml:


<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>


in app.js:


requires: [
'Ext.MessageBox',
'Ext.device.Accelerometer',
'Ext.device.Compass',
'Ext.device.Geolocation',
'Ext.device.Connection',
'Ext.device.Device'
],


code is bound to tabpanel show event and replaces active item html content:


Ext.device.Geolocation.watchPosition({
frequency: 3000, // Update every 3 seconds
callback: function(position) {
out.setHtml(out.getHtml() + [
'lat: ' + position.coords.latitude,
'lon: ' + position.coords.longitude,
'alt: ' + position.coords.altitude
].join('<br>'));
},
failure: function(e) {
out.setHtml(out.getHtml() + e.code + ': ' + e.message);
}
});


All works fine on my notebook (chrome and firefox browsers) but nothing is printed on phone's screen :(

in Settings -> Application Manager on my phone I see that my test app has permissions:

Your location - approximate (network-based) location, precise (GPS) location
Network communication - full network access
Network communication - view network connections

So probably it's not permissions issue.

a3366873
8 Oct 2013, 2:39 PM
just for the record - setting enableHighAccuracy: true on Ext.device.Geolocation.getCurrentPosition did the trick :)