我有一个 Android 应用程序,它基本上只是一个加载使用 Intel 的 App Framework 2.2 编写的 html 页面的 web 视图。自去年以来一直运行良好。但是,在运行 Android 5 的新三星 Note 4 上,应用程序加载,显示第一个面板,但我无法导航到页面上的任何链接。任何人有类似的问题并设法解决它?
以下是我的应用程序和 html 的相关代码。
_wv = (WebView)findViewById(R.id.browser);
WebSettings ws = _wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setUseWideViewPort(true);
_wv.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//Log.d("SGC", "shouldOverrideUrlLoading " + url);
if (Uri.parse(url).getHost().equals(getString(R.string.app_url))) {
return false;
}
// Otherwise, give the default behavior (open in browser)
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
});
_wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
myToast.setText("Loading... " + progress + "%");
myToast.show();
}
});
_wv.loadUrl("http://" + getString(R.string.app_url) + "/" + getString(R.string.app_url_name) + "/index.html");
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<WebView
android:id="@+id/browser"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
索引.html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<script src="../js/appframework.min.js" type="text/javascript"></script>
<script src="../js/appframework.ui.min.js" type="text/javascript"></script>
<link href="../css/af.ui.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="afui">
<div id="content">
<div class="panel" id="page_main" selected="selected" data-header="header_main">
<a href=“#page_product”>Products</a>
</div>
<div class="panel" id="page_product" data-header="header_back" >
<p>Our products</p>
<a href="#page_main">BACK</a>
</div>
</div>
<header id="header_main">
<h1>Company</h1>
</header>
<header id="header_back">
<h1>Our Products</h1>
</header>
</div>
</body>
</html>