I have installed Cordova 5.0.0 with these plugins:
cordova plugin list
cordova-plugin-device 1.0.1-dev "Device"
cordova-plugin-geolocation 1.0.0 "Geolocation"
cordova-plugin-globalization 1.0.0 "Globalization"
cordova-plugin-inappbrowser 1.0.1-dev "InAppBrowser"
cordova-plugin-network-information 1.0.0 "Network Information"
cordova-plugin-whitelist 1.0.1-dev "Whitelist"
Running this code on any android virtual device:
onDeviceReady: function () {
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
// onError Callback receives a PositionError object
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
var options = { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true };
navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
}
Return:
D/CordovaNetworkManager( 1239): Connection Type: 3g
D/CordovaNetworkManager( 1239): Connection Extra Info: epc.tmobile.com
D/CordovaWebViewImpl( 1239): onPageFinished(file:///android_asset/www/index.html)
D/dalvikvm( 1239): GC_EXTERNAL_ALLOC freed 457K, 49% free 3174K/6151K, external 901K/1038K, paused 3ms
I/InputReader( 843): Device reconfigured: id=0x0, name=qwerty2, display size is now 240x400
I/InputManager-Callbacks( 843): No virtual keys found for device qwerty2.
D/SystemWebChromeClient( 1239): file:///android_asset/www/js/app.js: Line 127 : code: 3
D/SystemWebChromeClient( 1239): message: Timeout expired
Why always returns timeout expired?
It could sound stupid, but, did you activate the "GPS" option in your phone?