Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
How do I get the geolocation service working on Android Webview

I tried to enable the geolocation service for the webview, but it never asks for it. I then enabled the service via settings, and it times out every time I try to use it. Is there any problem? Here's my code in MainActivity.java:

package com.example.quickweather;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.webkit.*;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView daApp = (WebView)findViewById(R.id.DaApp);
        WebSettings props = daApp.getSettings();
        props.setJavaScriptCanOpenWindowsAutomatically(true);
        props.setJavaScriptEnabled(true);
        props.setGeolocationEnabled(true);
        props.setAllowFileAccessFromFileURLs(true);
        props.setAllowFileAccess(true);
        props.setAppCacheEnabled(true);
        props.setDatabaseEnabled(true);
        props.setDomStorageEnabled(true);
        props.setAllowContentAccess(true);
        daApp.setWebChromeClient(new WebChromeClient(){
            @Override
            public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback){
                callback.invoke(origin,true,false);
            }
        });
     
        daApp.loadUrl("file:///android_asset/webinterface/index.html");
    }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda