简体   繁体   English

android 地理位置 html5

[英]android GeoLocation html5

Hi I am trying to load a webview that uses javascript and html5.嗨,我正在尝试加载使用 javascript 和 html5 的 webview。 However, I still can't access the location inside the application.但是,我仍然无法访问应用程序内的位置。 I have searched through the site and found some suggestions but I am still unable to access the location.我已经搜索了该站点并找到了一些建议,但我仍然无法访问该位置。 Here is my code snippet这是我的代码片段

private void openWebViewTab(){
final LinearLayout holderLayout = (LinearLayout)findViewById(R.id.home_holder);
final View myHolderView = View.inflate(MyWebViewActivity.this, R.layout.my_webview, null);
final WebView myWebView = (WebView) myHolderView.findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setGeolocationEnabled(true);
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.loadUrl(url);
}

private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
    view.loadUrl(url);
    return true;
}

} }

here is my Manifestfile:这是我的清单文件:

<uses-permission
    android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
    android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
    android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
    android:name="android.permission.INTERNET" />

Thanks in Advance for your help Switch在此先感谢您的帮助

you need a instance of WebChromeClient extending.您需要扩展 WebChromeClient 的实例。 the method of onGeolocationPermissionsShowPrompt Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin. onGeolocationPermissionsShowPrompt 方法指示客户端显示提示,要求用户设置指定来源的地理定位权限 state。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM