2013-05-15 63 views
0

Cordova發生了一件奇怪的事情,即使是最簡單的代碼也不行。代碼工作得很好,但從昨天開始不是。我沒有更改manifest.xml或任何其他文件中的任何內容。它是我的設備嗎?Phonegap正常工作,但現在不是

<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> 

現在我不能再運行科爾多瓦了。這是我得到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

它現在可以工作,但getcurrentposition不會工作了...... – Frank

回答

0

phonegap插件:相機,加速器等工程,但地理位置沒有。 這是所有權限都安裝像以前一樣代碼:

<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> 

但變量「位置」沒有設置什麼的,這個插件在工作前,現在還不是。 :(

+0

重新啓動設備的工作原理! – Frank

相關問題