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

时间:2015-01-21 10:58:44

标签: javascript android cordova bluetooth

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

这一切都完美无瑕,直到我尝试连接或断开蓝牙键盘(在我的情况下是Kensington KeyFolio Expert)。在这种情况下,会发生这种情况:

  1. 页面重新加载
  2. webview等待20秒(我认为这是Cordova的默认超时?)
  3. 弹出标题为Application Error的提醒,说:
  4.   

    与服务器的连接失败。 (javascript:try {cordova.require(' cordova / channel')。onDestroy.fire();} catch(e){console.log('异常触发来自本地' );};)

    或者,正确缩进:

    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');
     };)
    

    我在互联网上搜索了一下解决方案,据说有人应该“哄骗”。 cordova,使用下面的HTML。

    <!doctype html>
    <html>
        <head>
            <title></title>
            <script>
                window.location='./actual.html';
            </script>
        <body>      
        </body>
    </html>
    

    但它无济于事。问题依然存在。其他主题说我应该使用loadUrlTimeoutValue来增加this.setIntegerProperty("loadUrlTimeoutValue", 60000);,但是:无效(加上我的脚本运行时间不超过2秒,因为它全部是本地的)。

    这是我(dis)连接蓝牙键盘时发生的堆栈跟踪:

        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');};"})
    

    显然,我的问题是:为什么会发生这种情况,我该如何解决这个问题?

0 个答案:

没有答案