我需要从 web 视图中获取用户的位置,并且它不要求我获得获取位置的权限。下面是我的 webview 代码:
网络视图设置
public void WebViewSettings(){
webView = (WebView) findViewById(R.id.webview);
webView.canGoBack();
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.setWebViewClient(new WebViewClientSetup());
//webView.setWebChromeClient(new GeoWebChromeClient());
webView.getSettings().setGeolocationEnabled(true);
//webView.getSettings().setGeolocationDatabasePath( context.getFilesDir().getPath() );
myTimer = new Timer();
//Start this timer when you create you task
myTimer.schedule(new loaderTask(), 20000);
}
WebChrome客户端:
public class GeoWebChromeClient extends WebChromeClient {
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
}
}
网络视图客户端:
public class WebViewClientSetup extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onLoadResource(WebView view, String url) {
// Check to see if there is a progress dialog
if (progressDialog == null) {
progressDialog = new ProgressDialog(context);
progressDialog.setTitle("Loading...");
progressDialog.setMessage("Please wait.");
progressDialog.setCancelable(true);
progressDialog.setIndeterminate(true);
progressDialog.show();
}
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
handler.proceed();
}
@Override
public void onPageFinished(WebView view, String url) {
isPageLoadedComplete = true;
View mapHeight = (View) findViewById(R.id.webview);
int height = mapHeight.getHeight();
Log.d("map height", "map height" + height);
// Page is done loading;
// hide the progress dialog and show the webview
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
@Override
public void onReceivedError(WebView view, int errorCod,
String description, String failingUrl) {
AlertDialog();
}
}
它没有征求我的许可,我不知道为什么,任何人都可以看到我要去哪里错了吗?提前致谢!