gpt4 book ai didi

android - E/DroidGap(21383) : DroidGap: TIMEOUT ERROR! - 调用 webViewClient

转载 作者:行者123 更新时间:2023-11-29 02:07:27 31 4
gpt4 key购买 nike

我使用 phonegap 1.3.0 开发移动应用程序。当我单击一个将调用我的插件以调用 js 函数的按钮时,大约 20 秒后,在 eclipse 日志控制台中出现错误:“E/DroidGap(21383): DroidGap: TIMEOUT ERROR! - calling webViewClient”。并且仿真器会弹出一个对话框,显示错误消息:与服务器的连接不成功。(javascript:showProcessBar(1))我该如何修复错误?谢谢!

下面有一些细节可以补充我的问题。当我在 phonegap 插件中调用 js 函数时。 logcat 中一定会显示错误消息:“E/DroidGap(21383): DroidGap: TIMEOUT ERROR! - calling 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, "The connection to the server was successful.", url);因为它会提醒对话框终止我的程序。

最佳答案

Android 在 WebView 中加载 URL 时强制超时。

查看此链接,(它实际上与 JQM 无关),但 phonegap android http://jquerymobile.com/test/docs/pages/phonegap.html

关于android - E/DroidGap(21383) : DroidGap: TIMEOUT ERROR! - 调用 webViewClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9246600/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com