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 7435585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:54+00:00 2026-05-29T10:05:54+00:00

I am writing an Android web app (I will not upload the APP to

  • 0

I am writing an Android “web” app (I will not upload the APP to the web, but set the HTML+JS inside the application resources). That means, the GUI will be HTML5, and I will use another “native” thread to read from the microphone and hopefully send the “parsed text” to the HTML5/JS code.

Is this possible? In the Android code, I see how can I call native code from JS (and I want the opposite).

http://developer.android.com/guide/webapps/webview.html

  • 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-29T10:05:55+00:00Added an answer on May 29, 2026 at 10:05 am

    Yes, Android rocks at this actually.

    I’m posting example code from a random example app that I made but this should get you going.

    Lets start by supposing you have to global variable to your webview controlling class:

    String name = "John";
    String lastName = "Doe";
    

    In the Android class controlling the webview (during onCreate() or when you setup your webview):

    webView.addJavascriptInterface(new JavaScriptInterface(), "android")
    

    Inner class to your webview controlling class:

    /**
    * Sets up the interface for getting access to Latitude and Longitude data
    * from device
    **/
    private class JavaScriptInterface {
        public String getName() {
            return name;
        }
        public String getLastName() {
            return lastName;
        }
        public void onJavascriptButtonPushed(String text) {
            Toast.makeText(WebViewControllingClass.this, "The text of the pressed button is: "+text,Toast.LENGTH_SHORT).show();
        }
    }
    

    Thats it for the Android side, now to use it through Javascript:

    To get the name and lastname through JavaScript:

    if (window.android){
        name = window.android.getName();
        lastName = window.android.getLastName();
    }
    

    If you want to raise the toast, set a javascript whose function would be:

    if (window.android){
        window.android.onJavascriptButtonPushed("Hello");
    }
    

    Edit:

    I havent tried this, but a search yielded this, try it out, it should work.

    If you want to use it in the other direction:

    JS:

    function testEcho(message){
         window.JSInterface.doEchoTest(message);
    }
    

    Android:

    myWebView.loadUrl("javascript:testEcho('Hello World!')");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web and Android app that allows users to store and access
I am writing an application that initially will be developed as web (probably Silverlight)
I am writing an Android application that interfaces with a RESTful service. This web
I'm writing an Android application that I want to be able to send requests
I'm writing an Android app where users can upload video to Youtube. I'd like
I'm writing an android application that draws directly to the canvas on the onDraw
I'm writing my first android app (I'm a noob at android, but decent at
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I'm currently writing an app in Android that works with the GPS. At the
I'm writing an Android app that contains a contact list. The design required me

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.