2012-02-12 5 views
2

私はphonegap 1.3.0を使ってモバイルアプリケーションを開発しています。 約20秒後にjs関数を呼び出すためのプラグインを呼び出すボタンをクリックすると、Eclipseのログコンソールで "E/DroidGap(21383):DroidGap:TIMEOUT ERROR! - calling webViewClient"というエラーが返されました。 エミュレータがダイアログに警告を表示すると、エラーメッセージが表示されます。サーバーへの接続に失敗しました(javascript:showProcessBar(1)) エラーを修正するにはどうすればよいですか?ありがとう!E/DroidGap(21383):DroidGap:タイムアウトエラー! - webViewClientを呼び出す

私の質問を補完するために、以下にいくつかの詳細があります。 私はphonegapプラグインでjs関数を呼び出します。 logcat: "E/DroidGap(21383):DroidGap:TIMEOUT ERROR! - webViewClientの呼び出し"にエラーメッセージが表示されます。

エラーを生成するコードが見つかりました。すぐ下:

private void loadUrlIntoView(final String url) { 
    if (!url.startsWith("javascript:")) { 
     LOG.d(TAG, "DroidGap.loadUrl(%s)", url); 
    } 

    this.url = url; 
    if (this.baseUrl == null) { 
     int i = url.lastIndexOf('/'); 
     if (i > 0) { 
      this.baseUrl = url.substring(0, i+1); 
     } 
     else { 
      this.baseUrl = this.url + "/"; 
     } 
    } 
    if (!url.startsWith("javascript:")) { 
     LOG.d(TAG, "DroidGap: url=%s baseUrl=%s", url, baseUrl); 
    } 

    // Load URL on UI thread 
    final DroidGap me = this; 
    this.runOnUiThread(new Runnable() { 
     public void run() { 

      // Init web view if not already done 
      if (me.appView == null) { 
       me.init(); 
      } 

      // Handle activity parameters 
      me.handleActivityParameters(); 

      // Track URLs loaded instead of using appView history 
      me.urls.push(url); 
      me.appView.clearHistory(); 

      // Create callback server and plugin manager 
      if (me.callbackServer == null) { 
       me.callbackServer = new CallbackServer(); 
       me.callbackServer.init(url); 
      } 
      else { 
       me.callbackServer.reinit(url); 
      } 
      if (me.pluginManager == null) { 
       me.pluginManager = new PluginManager(me.appView, me);   
      } 
      else { 
       me.pluginManager.reinit(); 
      } 

      // If loadingDialog property, then show the App loading dialog for first page of app 
      String loading = null; 
      if (me.urls.size() == 1) { 
       loading = me.getStringProperty("loadingDialog", null); 
      } 
      else { 
       loading = me.getStringProperty("loadingPageDialog", null);     
      } 
      if (loading != null) { 

       String title = ""; 
       String message = "Loading Application..."; 

       if (loading.length() > 0) { 
        int comma = loading.indexOf(','); 
        if (comma > 0) { 
         title = loading.substring(0, comma); 
         message = loading.substring(comma+1); 
        } 
        else { 
         title = ""; 
         message = loading; 
        } 
       } 
       me.spinnerStart(title, message); 
      } 

      // Create a timeout timer for loadUrl 
      final int currentLoadUrlTimeout = me.loadUrlTimeout; 
      Runnable runnable = new Runnable() { 
       public void run() { 
        try { 
         synchronized(this) { 
          wait(me.loadUrlTimeoutValue); 
         } 
        } catch (InterruptedException e) { 
         e.printStackTrace(); 
        } 

        // If timeout, then stop loading and handle error 
        if (me.loadUrlTimeout == currentLoadUrlTimeout) { 
         me.appView.stopLoading(); 
         LOG.e(TAG, "DroidGap: TIMEOUT ERROR! - calling webViewClient"); 
         //me.webViewClient.onReceivedError(me.appView, -6, "The connection to the server was unsuccessful.", url); 
        } 
       } 
      }; 
      Thread thread = new Thread(runnable); 
      thread.start(); 
      me.appView.loadUrl(url); 
     } 
    }); 
} 

私は行をコメント:me.webViewClient.onReceivedError(me.appView、-6は、 "サーバーへの接続に失敗しました。"、URLを);それは私のプログラムを終了するダイアログを警告するので。

+0

でのJavaコードでこの行はこれが役立つかもしれない

場所:http://stackoverflow.com/questions/8339136/how-to-use-external-image-inside-phonegap-jquerymobile-app – jeremy

答えて

1

のAndroidは、タイムアウトが適用されます。

navigator.onLine; 

あなたはここで働いそれを見ることができます。

チェックアウトこのリンクを、(それは本当にJQMに関係しない)が、PhoneGapのアンドロイド http://jquerymobile.com/test/docs/pages/phonegap.html

0

この問題は、外部URLへのPhoneGap呼び出しで応答がtime outの場合、そのエラーをスローします。

ができませインターネット接続をチェックするには、このHTML5の機能:WebViewの中にURLをロードするときhttp://html5demos.com/nav-online

0

super.setIntegerProperty( "loadUrlTimeoutValue"、60000);活動

関連する問題