title: getting location in WebView via js
body: <p>I am trying to create WebView which would get GPS localization via js, but when i click on button which should show localization:
  in android 4.1.1(emulator): "Error code 2. Failed to start Geolocation service
  in android 4.1.2(phone) just nothing happens
  in android 6.0(emulator) the same, just nothing happens</p>
  
  <p>My permissions:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
  </code></pre>
  
  <p>My settings:</p>
  
  <pre><code>webView.getSettings().setJavaScriptEnabled(true);
          webView.getSettings().setGeolocationEnabled(true);
          webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
          webView.getSettings().setBuiltInZoomControls(true);
  
          webView.getSettings().setSaveFormData(false);
          webView.getSettings().setSavePassword(false);
          webView.getSettings().setAppCacheEnabled(true);
          webView.getSettings().setDatabaseEnabled(true);
          webView.getSettings().setDomStorageEnabled(true);
          webView.getSettings().setGeolocationDatabasePath(getFilesDir().getPath());
  </code></pre>
  
  <p>WebChromeClient:</p>
  
  <pre><code>WebChromeClient webChromeClient = new WebChromeClient(){
  
              @Override
              public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
                  // callback.invoke(String origin, boolean allow, boolean remember);
                  callback.invoke(origin, true, false);
              }
  
              public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType, String capture){
                  mUploadMessage = uploadMsg;
                  Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                  i.addCategory(Intent.CATEGORY_OPENABLE);
                  i.setType("*/*");
                  MainActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);
  
              }
  
              public boolean onShowFileChooser (WebView webView, ValueCallback&lt;Uri[]&gt; filePathCallback, WebChromeClient.FileChooserParams fileChooserParams){
                  Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                  i.addCategory(Intent.CATEGORY_OPENABLE);
                  i.setType("*/*");
                  MainActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);
                  return false;
              }
  
          };
  </code></pre>
  
  <p>WebViewClient:</p>
  
  <pre><code>WebViewClient webViewClient = new WebViewClient(){
              @Override
              public boolean shouldOverrideUrlLoading(WebView view, String url){
                  view.loadUrl(url);
                  return true;
              }
  
              public void onPageFinished(WebView view, String url){
                  progressBar.setVisibility(View.GONE);
                  webView.setVisibility(View.VISIBLE);
                  refreshBtn.setVisibility(View.VISIBLE);
              }
          };
  </code></pre>
  
  <p>at the end, i have this line of code:</p>
  
  <pre><code>ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 0);
  </code></pre>
  
  <p>and js code (not my code):</p>
  
  <pre><code>    &lt;script&gt;
  function getLocationConstant()
  {
    if(navigator.geolocation)
    {
     navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError);
    } else {
     alert("Brak obsługi GPS");
    }
  }
  
  
  function onGeoSuccess(event)
  {
    document.getElementById("skad").value =  event.coords.latitude+", "+event.coords.longitude;
   document.getElementById('szk').click();
  
  }
  
  
  function onGeoError(event)
  {
    alert("Error code " + event.code + ". " + event.message);
  }
  
  
  &lt;/script&gt;
  
  &lt;input type="text" name="skad" style="width:278px;" id="skad" &gt;
  </code></pre>