I have searched and read a lot of posts but can not figure out how to do it in my code.
I want to use geolocation in my app and need to view in webChromeClient in stead of webViewClient which I use for the html files now and the links does stay in the same view.
When I change this to webChromeClient, the html links, like <a href="http://url/file.php?q=123"
, are suddenly opening in the browser!
How can I prevent this?
myWebView = new WebView(this);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setGeolocationEnabled(true);
myWebView.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, android.webkit.GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false); }
});
myWebView.loadUrl("file:///android_asset/HTML/index.html");
setContentView(myWebView);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…