Javascript (dis)连接蓝牙键盘时Cordova崩溃

Javascript (dis)连接蓝牙键盘时Cordova崩溃,javascript,android,cordova,bluetooth,Javascript,Android,Cordova,Bluetooth,我有一个与PhoneGap/Cordova 2.5.0结合使用Android的应用程序。我有所有的HTML页面和javascript文件等本地;我不调用外部URL 在我尝试连接或断开蓝牙键盘(在我的例子中是肯辛顿键盘专家)之前,这一切都是完美无瑕的。在这种情况下,会发生以下情况: 页面将重新加载 webview等待大约20秒(我认为这是cordova默认超时?) 弹出一个标题为“应用程序错误”的警报,说明: 与服务器的连接不成功。(javascript:try{cordova.require('

我有一个与PhoneGap/Cordova 2.5.0结合使用Android的应用程序。我有所有的HTML页面和javascript文件等本地;我不调用外部URL

在我尝试连接或断开蓝牙键盘(在我的例子中是肯辛顿键盘专家)之前,这一切都是完美无瑕的。在这种情况下,会发生以下情况:

  • 页面将重新加载
  • webview等待大约20秒(我认为这是cordova默认超时?)
  • 弹出一个标题为“应用程序错误”的警报,说明:
  • 与服务器的连接不成功。(javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};)

    或者,适当缩进:

    The connection to the server was unsuccessful.    
     (javascript: try {
         cordova.require('cordova/channel').onDestroy.fire();
     } catch (e) {
         console.log('exception firing destroy event from native');
     };)
    
    我在互联网上搜索了一些解决方案,据说应该使用下面的HTML“欺骗”cordova

    <!doctype html>
    <html>
        <head>
            <title></title>
            <script>
                window.location='./actual.html';
            </script>
        <body>      
        </body>
    </html>
    
    很明显,我的问题是:为什么会发生这种情况,我该如何解决

        01-21 11:53:56.216: D/DroidGap(17945): Paused the application!
        01-21 11:53:56.216: D/CordovaWebView(17945): Handle the pause
        01-21 11:53:56.257: D/DroidGap(17945): onDestroy()
        01-21 11:53:56.258: D/CordovaWebView(17945): >>> loadUrl(javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};)
        01-21 11:53:56.258: D/CordovaWebView(17945): >>> loadUrlNow()
        01-21 11:53:56.304: D/DroidGap(17945): Setting boolean properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml
        01-21 11:53:56.305: D/DroidGap(17945): DroidGap.onCreate()
        01-21 11:53:56.310: W/art(17945): Attempt to remove local handle scope entry from IRT, ignoring
        01-21 11:53:56.312: W/AwContents(17945): onDetachedFromWindow called when already detached. Ignoring
        01-21 11:53:56.319: D/JsMessageQueue(17945): Set native->JS mode to 2
        01-21 11:53:56.319: W/art(17945): Attempt to remove local handle scope entry from IRT, ignoring
        01-21 11:53:56.320: W/art(17945): Attempt to remove local handle scope entry from IRT, ignoring
        01-21 11:53:56.320: D/DroidGap(17945): DroidGap.init()
        01-21 11:53:56.391: D/FileManager.getPathFromIdentifier (98)(17945): getting path from ident:, /storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/d0.html
        01-21 11:53:56.447: D/CordovaWebView(17945): DroidGap.loadUrl(file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/d0.html, 70000)
        01-21 11:53:56.447: D/DroidGap(17945): onMessage(splashscreen,show)
        01-21 11:53:56.447: D/CordovaWebView(17945): >>> loadUrl(file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/d0.html)
        01-21 11:53:56.447: D/PluginManager(17945): init()
        01-21 11:53:56.450: D/CordovaWebView(17945): >>> loadUrlNow()
        01-21 11:53:56.469: D/DroidGap(17945): onMessage(onPrepareOptionsMenu,com.android.internal.view.menu.MenuBuilder@39be6cf1)
        01-21 11:53:56.476: D/DroidGap(17945): onMessage(onPrepareOptionsMenu,com.android.internal.view.menu.MenuBuilder@39be6cf1)
        01-21 11:53:56.477: D/DroidGap(17945): Resuming the App
        01-21 11:53:56.540: D/SoftKeyboardDetect(17945): Ignore this event
        01-21 11:53:56.607: D/SoftKeyboardDetect(17945): Ignore this event
        01-21 11:53:56.627: D/SoftKeyboardDetect(17945): Ignore this event
        01-21 11:53:56.649: D/DroidGap(17945): onMessage(onPageStarted,file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/d0.html)
        01-21 11:53:56.714: D/DroidGap(17945): onMessage(onPageStarted,file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/0.html)
        01-21 11:53:57.061: D/Cordova(17945): onPageFinished(file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/0.html)
        01-21 11:53:57.061: D/Cordova(17945): Trying to fire onNativeReady
        01-21 11:53:57.062: D/DroidGap(17945): onMessage(onNativeReady,null)
        01-21 11:53:57.062: D/DroidGap(17945): onMessage(onPageFinished,file:///storage/emulated/0/Android/data/com.example.cordovatest/b51d8994b23e24a4b1f3211d8324a66f714ca802/1050/0.html)
        01-21 11:53:57.148: D/CordovaNetworkManager(17945): Connection Type: wifi
        01-21 11:53:57.151: D/CordovaNetworkManager(17945): Connection Type: wifi
        01-21 11:53:57.151: D/DroidGap(17945): onMessage(networkconnection,wifi)
        01-21 11:53:57.155: D/DroidGap(17945): onMessage(spinner,stop)
        01-21 11:53:59.067: D/DroidGap(17945): onMessage(spinner,stop)
        01-21 11:54:16.290: E/CordovaWebView(17945): CordovaWebView: TIMEOUT ERROR!
        01-21 11:54:16.290: D/Cordova(17945): CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=javascript:try{cordova.require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};
        01-21 11:54:16.291: D/DroidGap(17945): onMessage(onReceivedError,{"errorCode":-6,"description":"The connection to the server was unsuccessful.","url":"javascript:try{cordova.require('cordova\/channel').onDestroy.fire();}catch(e){console.log('exception firing destroy event from native');};"})