我使用phonegap 1.3.0開發移動應用程序。 當我點擊一個按鈕,將調用我的插件調用一個js函數,大約20s後,反對錯誤:「E/DroidGap(21383):DroidGap:超時錯誤! - 在eclipse日誌控制檯調用webViewClient」。 和模擬器警告一個對話框,顯示錯誤消息:到服務器的連接不成功。(javascript:showProcessBar(1)) 我該如何解決這個錯誤?謝謝!E/DroidGap(21383):DroidGap:TIMEOUT ERROR! - 調用webViewClient
下面有一些細節來補充我的問題。 當我調用手機插件中的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 「到服務器的連接失敗」,網址);因爲它會提醒一個對話框來終止我的程序。
這可能幫助:http://stackoverflow.com/questions/8339136/how-to-use-external-image-inside-phonegap-jquerymobile-app – jeremy 2012-02-13 11:49:52