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

193
Vistas
Get value from a html page in Webview with Javascript

I have been trying to get a value from a class from the web page loaded in Webview

I've been searching for answers however I have tried many codes but it just didn't work at all

All I want to do is

  1. get the value from the html page
  2. assign it to a variable inside Java

I know that I have to use Java interface I have tried the following code but it just do not work

Inside WebViewClient

public void onPageFinished(WebView view, String url) {
wv.loadUrl("javascript: alert(function(){setTimeout(function(){var recieved_poin = document.querySelector(\".point\").innerHTML" +
                                "console.log(recieved_poin);}, 500);})();"); // input Id and password
}

Inside WebChromeClient

@Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            Log.d("LogTag", message);
            Toast.makeText(getActivity(), "value recieved from class is "+message, Toast.LENGTH_SHORT).show();
            result.confirm();
            return true;
        }

I am using getActivity() in toast because I'm inside a fragment

please help me out

about 4 years ago · Santiago Gelvez
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