Hi I am trying to load a webview that uses javascript and html5. 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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.