Cordova发生了一件奇怪的事情,即使是最简单的代码也不再适用。代码工作得很好,但从昨天开始就没有。我没有在manifest.xml或任何其他文件中更改任何内容。这是我的设备吗?
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
function onload(){
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is ready
//
function onDeviceReady() {
alert('test')
var element = document.getElementById('deviceProperties');
console.log('test');
element.innerHTML = 'Device Name: ' + device.name + '<br />' +
'Device Cordova: ' + device.cordova + '<br />' +
'Device Platform: ' + device.platform + '<br />' +
'Device UUID: ' + device.uuid + '<br />' +
'Device Model: ' + device.model + '<br />' +
'Device Version: ' + device.version + '<br />';
}
</script>
现在我不能再运行cordova了。这就是我在logcat
中得到的:
05-15 11:46:33.478: I/CordovaLog(26092): Changing log level to DEBUG(3) 05-15 11:46:33.478: I/CordovaLog(26092): Found preference for useBrowserHistory=true 05-15 11:46:33.478: D/CordovaLog(26092): Found preference for useBrowserHistory=true 05-15 11:46:33.478: I/CordovaLog(26092): Found preference for exit-on-suspend=false 05-15 11:46:33.478: D/CordovaLog(26092): Found preference for exit-on-suspend=false 05-15 11:46:33.483: I/CordovaLog(26092): Found preference for loadingDialog=MORE, Loading... 05-15 11:46:33.483: D/CordovaLog(26092): Found preference for loadingDialog=MORE, Loading... 05-15 11:46:33.503: D/JsMessageQueue(26092): Set native->JS mode to 2 05-15 11:46:33.508: D/DroidGap(26092): DroidGap.init() 05-15 11:46:33.618: D/CordovaWebView(26092): >>> loadUrl(file:///android_asset/www/index.html) 05-15 11:46:33.618: D/PluginManager(26092): init() 05-15 11:46:33.623: D/CordovaWebView(26092): >>> loadUrlNow() 05-15 11:46:33.628: D/DroidGap(26092): Resuming the App 05-15 11:46:33.688: D/SoftKeyboardDetect(26092): Ignore this event 05-15 11:46:33.698: D/DroidGap(26092): onMessage(onPageStarted,file:///android_asset/www/index.html) 05-15 11:46:34.088: D/SoftKeyboardDetect(26092): Ignore this event 05-15 11:46:36.068: D/Cordova(26092): onPageFinished(file:///android_asset/www/index.html) 05-15 11:46:36.068: D/DroidGap(26092): onMessage(onNativeReady,null) 05-15 11:46:36.068: D/DroidGap(26092): onMessage(onPageFinished,file:///android_asset/www/index.html) 05-15 11:46:38.068: D/DroidGap(26092): onMessage(spinner,stop) 05-15 11:46:38.353: W/dalvikvm(26092): disableGcForExternalAlloc: false
有什么问题?
答案 0 :(得分:0)
手机插头插件:相机,加速器等工作但地理位置不行。 这是代码,所有权限都像以前一样安装:
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
console.log('test');
alert('test');
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
// onSuccess Geolocation
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
console.log(position.coords.latitude);
element.innerHTML =
'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'Altitude: ' + position.coords.altitude + '<br />' +
'Accuracy: ' + position.coords.accuracy + '<br />' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' +
'Heading: ' + position.coords.heading + '<br />' +
'Speed: ' + position.coords.speed + '<br />' +
'Timestamp: ' + position.timestamp + '<br />';
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
但变量“position”没有设置或者其他东西,这个插件现在还没有工作。 :(