我刚开始使用android编码,我仍然从错误中学习。我使用WebView加载内部html页面,我想要打开另一个活动窗口,该窗口将是barcode scanner,方法是单击webview上的超链接。不过,我得到这个错误无法打开资源URL:file:/// android_asset/activity_a
Unable to open asset URL: file:///android_asset/activity_a://qrcodeactivity
AndroidManifest.xml中
的index.html
MyWebClient的Java
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.equals("activity_a://qrcodeactivity")) {
Intent intent = new Intent(getContext(), qrcodeactivity.class);
startActivity(intent);
return true; // Handle By application itself
} else {
view.loadUrl(url);
if (loader.equals("pull")) {
swipeContainer.setRefreshing(true);
} else if (loader.equals("dialog")) {
if (!pd.isShowing()) {
pd.show();
}
} else if (loader.equals("never")) {
Log.d("WebView", "No Loader selected");
}
return true;
}
}
@Override
public void onPageFinished(WebView view, String url) {
if (pd.isShowing()) {
pd.dismiss();
}
if (swipeContainer.isRefreshing()) {
swipeContainer.setRefreshing(false);
}
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
webView.loadUrl("file:///android_asset/" + getString(R.string.error_page));
}
}