Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!