作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚收到分包商提供的 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"
有没有人遇到过类似的问题?关于如何调试错误的任何建议?
更新
按照 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);
}
}
最佳答案
如果没有看到您的 index.html
代码,就很难判断您是否正确引用了您的 css 文件。此外,该网址:file:///android_asset/www/car.html=carID=106
似乎无效? =carID=106
有什么用?正确的 URL 应该是 ?carID=106
。但是等等还有更多,Android 上有一个错误,无法正确读取 url 参数。
这是 Android 上的一个错误。你应该给它加注星标:
https://code.google.com/p/android/issues/detail?id=17535
同时使用 localStorage.setItem()
/getItem()
在页面之间传递值。
关于android - 使用 Eclipse 测试 PhoneGap 应用程序时不断获取 "A network error occurred",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10433978/
我是一名优秀的程序员,十分优秀!