问题描述
我刚刚从分包商那里收到了来自分包商的Phonegap解决方案,以便在启动之前在我的手机上进行测试.
我将项目导入日食,一切都很好.
我可以通过打开index.html文件在计算机上本地测试该应用程序:
file://E:/AppDevelopment/Workspace/myproject/assets/www/index.html
到目前为止一切都很好.然后,我尝试启动我的手机(通过USB Cabel).首页打开了,但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()传递页面之间的值.
其他推荐答案
您可以设置 webViewClol"> webviewclient 到您的网络视图,和Ovveride onReceivedError方法.
其他推荐答案
您可能需要使用icecreamCordovawebViewClient
@Override public void init() { super.init(webView, new IceCreamCordovaWebViewClient(this, webView), new CordovaChromeClient(this, webView)); }
问题描述
I've just received the PhoneGap solution from by sub-contractor in order to test it on my phone before launch.
I import the project into Eclipse and it all looks fine.
I can test the app locally on my computer by opening the index.html file:
file://E:/AppDevelopment/Workspace/myproject/assets/www/index.html
So far so good. Then I try launching this an my phone ( via USB cabel). The front page opens, but the CSS is missing. And when I click any link, I get the following message:
"A network error occurred. (file:///android_asset/www/car.html?carID=106"
Has anyone had similar problems? Any suggestions to how I can debug what is wrong?
UPDATE
Following Dmyto's suggestion, I'm trying to change the onReceivedError. But I only get coding errirs.
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); } }
推荐答案
Without seeing your index.html code it is hard to tell if you are referencing your css files properly. Also, that url: file:///android_asset/www/car.html=carID=106 doesn't seem valid? What is with the =carID=106? A proper URL should be ?carID=106. But wait there's more, there is a bug on Android where url paramters are not read properly.
It's a bug on Android. You should go star it:
https://code.google.com/p/android/issues/detail?id=17535
In the meantime use localStorage.setItem()/getItem() to pass values between pages.
其他推荐答案
You can set WebViewClient to your web view, and ovveride onReceivedError method.
其他推荐答案
You might need to use IceCreamCordovaWebViewClient
@Override public void init() { super.init(webView, new IceCreamCordovaWebViewClient(this, webView), new CordovaChromeClient(this, webView)); }