我有一個應用程序,可以在所有Api> 11包括Kitkat 4.4.2上正常工作。Complient鏈接URL不調用onPageFinished在WebView KitKat 4.4.4
然而,在奇巧4.4.4 onPageFinished()不燒成1條鏈路:
HREF = 「http://app.host.com/projects/30/edit/」
。
我知道KitKat WebView的問題,並從我知道這個網址應該工作。
與此URL對應的網絡應用程序是用RoR編寫的,並禁用了turbolinks。
我的WebView客戶端如下所示。
我花了好幾天的時間試圖讓這個工作。
如果有人發現任何錯誤,請告訴我。
// Set WebView client
mWebAppView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d(TAG, "#shouldOverrideUrlLoading url called: " + url);
// Open an email client on device when openning a mailto: link
if (MailTo.isMailTo(url)) {
Intent intent = null;
try {
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
view.getContext().startActivity(intent);
return true;
// open the help link in a browser.
} else if (url
.contains("www.host.com/expertise/business-development/index.cfm")) {
Log.d(TAG, "should open browser");
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
view.loadUrl(url);
return true;
}
}
@SuppressLint("InlinedApi")
@Override
public void onPageFinished(WebView view, String url) {
// super.onPageFinished(view, url);
view.clearCache(true);
Log.d(TAG, "#onPageFinished loaded page is :"+url);
if (pd.isShowing() && pd != null) {
pd.dismiss();
Log.d(TAG, "Inside #onPageFinished, pd dismissed");
}
// Change orientation for the table screen for phones so that
// the tables show correctly
if ((url.contains("projects"))
&& ((url.contains("stepfirst"))
|| (url.contains("stepsecond")) || (url
.contains("edit"))) && !isTablet) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else if (!isTablet) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
@Override
public void onLoadResource(WebView view, String url) {
// TODO Auto-generated method stub
super.onLoadResource(view, url);
Log.d(TAG, "Inside #onLoadResource url :"+url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
Log.d(TAG, "Inside #onPageStarted url :"+url);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view,
String url) {
// TODO Auto-generated method stub
Log.d(TAG, "Inside #shouldInterceptRequest url :"+url);
return super.shouldInterceptRequest(view, url);
}
});