Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Accsses geo location in webview

$
0
0

In Xamarin.android I created a webview like this :

               protected override void OnCreate(Bundle savedInstanceState)
                {
                        base.OnCreate(savedInstanceState);
                        SetContentView(Resource.Layout.activity_main);

                        var webView = FindViewById<WebView>(Resource.Id.webView);

                        webView.Settings.JavaScriptEnabled = true;
                        webView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
                        webView.Settings.DomStorageEnabled = true;
                        webView.Settings.SetGeolocationEnabled(true);
                        webView.Settings.SetAppCacheEnabled(true);
                        webView.SetWebChromeClient(new HybridWebViewChormClient());
                        webView.LoadUrl("myaddress");

                }

              public class HybridWebViewChormClient: WebChromeClient
                {
                    public override void OnGeolocationPermissionsShowPrompt(string origin, GeolocationPermissions.ICallback callback)
                    {
                        callback.Invoke(origin, true, false);

                    }


                }

and set this permission > Access_fine_location in android manifest
but the webview can't get access location
note : in external browser like chrome or Firefox access location works fine


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>