2012-02-12 1 views
2

나는 phonegap 1.3.0을 사용하여 모바일 응용 프로그램을 개발합니다. 약 20 초 후에 js 함수를 호출하기 위해 플러그인을 호출하는 버튼 하나를 클릭하면 Eclipse 로그 콘솔에서 "E/DroidGap (21383) : DroidGap : TIMEOUT ERROR! - 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

에서 자바 코드에서이 라인이 도움이 될

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

답변

0

문제는 자체적으로 설명합니다. 외부 URL에 대한 PhoneGap 호출에서 응답이 time out 인 경우 오류가 발생합니다.

할 수 있습니다 당신은 인터넷 연결을 확인하려면이 HTML5 기능 : 웹보기에 URL을로드 할 때 http://html5demos.com/nav-online

0

super.setIntegerProperty ("loadUrlTimeoutValue", 60000); 활동