Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:30:22+00:00 2026-05-24T04:30:22+00:00

I want to know if there is way to call javascript from java on

  • 0

I want to know if there is way to call javascript from java on android?
In my program, I interact java and javascript together. I am using java to receive response(json data) from TCP server and save them into a file. In webview I am using javascript jQuery getJSON() function to retrieve that file and using jQuery plot chart library to draw chart. Now, there is no relationship between java and javascript. Every time when I update data and file, I still need to click a button in webview to trigger the draw function. I want the programmes to be smart and handy. Is that a way to call or execute javascript from java. I know one way:

Button update = (Button)findViewById(R.id.update);
        update.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                wv.loadUrl("javascript:document.write('hello')");
            }
        });

But the problem is I already do a index page by loadurl().

final WebView wv = (WebView) findViewById(R.id.webkankan);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.loadUrl("file:///android_asset/index.html");

When I trigger this click event, all contents were gone only a string “hello” there. Another thing is why I need to change webview’s type to final to avoid eclipse error. Does this is the problem to trigger my main problem? If so, how can I fix it?
Thanks for you patience.
Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:30:23+00:00Added an answer on May 24, 2026 at 4:30 am

    For instance you have a javascript method in the index.html called loadData() which reads the file you saved in the java, then what you can do is wv.loadUrl("javascript:loadData()");. This actually call the javascript method and you can then read the file in that method. Hope this solves your problem.

    or in simple terms. jus do this webView.loadUrl("javascript:jsmethodname()"); to execute javascript from java.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if there is any way you can call and use
I am using sql server 2005. I just want to know is there something
I want to know is there any way to identify an html element by
i want to know is there any groovier way of code below: def dataList
Just want to know if there other optional wrapper framework available that generate client
I'd like to know if there's a better approach to this problem. I want
I would like to know the best way to delete records from a live
I know there is a way to import modules which are in a zip
does anyone know if there is a way to trigger the client side form
Question: Is there a way to make a function object in python using strings?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.