我刚刚收到分包商的PhoneGap解决方案,以便在启动之前在我的手机上对其进行测试。使用Eclipse测试PhoneGap应用程序时,出现“发生网络错误”
我将项目导入到Eclipse中,看起来一切正常。
我可以通过打开index.html文件进行本地测试应用程序在我的电脑上:
file://E:/AppDevelopment/Workspace/myproject/assets/www/index.html
到目前为止好。然后,我尝试启动这个我的手机(通过USB电缆)。首页打开,但CSS丢失。当我点击任何链接时,我会收到以下消息:
"A network error occurred. (file:///android_asset/www/car.html?carID=106"
有没有人有类似的问题?任何建议如何我可以调试什么是错的?
UPDATE
继Dmyto的建议,我试图改变onReceivedError。但我只能得到编码错误。
package com.phonegap.mysite;
import android.os.Bundle;
import org.apache.cordova.*;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Mysiteextends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
/** This is where it goes wrong **/
WebView webview = new WebView(this);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.i("WEB_VIEW_TEST", "error code:" + errorCode);
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
对不起,该网址是一个错字。我使用'?'而不是'='。正确的URL是'file:///android_asset/www/car.html?carID = 106'。正如我在Q中所述,当我在我的电脑(和Eclipse)上测试时,该应用程序工作正常,而不是在我的手机上。我没有编码Android应用程序的经验,所以**在各种代码的**处都非常空白。 – Steven
正确的是,你正在被Android操作系统中的错误绊倒。所以如果你想将信息从一个页面传递到另一个页面,你需要使用localStorage。 –
经过一番测试,你是绝对正确的。我的问题是;是否将使用localStorage适用于iOS和Windows手机? – Steven