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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:15:17+00:00 2026-06-09T00:15:17+00:00

Since the way you call javascript on a WebView is through loadUrl(javascript: … );

  • 0

Since the way you call javascript on a WebView is through loadUrl(“javascript: … “); The keyboard cannot stay open.

The loadUrl() method calls loadUrlImpl() , which calls a method called clearHelpers() which then calls clearTextEntry(), which then calls hideSoftKeyboard() and then we become oh so lonely as the keyboard goes away.

As far as I can see all of those are private and cannot be overridden.

Has anyone found a workaround for this? Is there a way to force the keyboard to stay open or to call the javascript directly without going through loadUrl()?

Is there anyway to override the WebView in a way to prevent (the private method) clearTextEntry() from being called?

  • 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-06-09T00:15:19+00:00Added an answer on June 9, 2026 at 12:15 am

    Update

    KitKat added a public method for invoking javascript directly: evaluateJavascript()

    For older apis, you could try a solution like below, but if I had to do this again I’d look at just building an compatibility method that on KitKat uses the above method and on older devices, uses reflection to drill down to a inner private method: BrowserFrame.stringByEvaluatingJavaScriptFromString()

    Then you could call javascript directly without having to deal with loadUrl and adding "javascript: " to the script.

    Old Answer

    As requested by Alok Kulkarni, I’ll give a rough overview of a possible workaround I thought of for this. I haven’t actually tried it but in theory it should work. This code is going to be rough and is just to serve as an example.

    Instead of sending the calls down through loadUrl(), you queue your javascript calls and then have javascript pull them down. Some thing like:

    private final Object LOCK = new Object();
    private StringBuilder mPendingJS;
    
    public void execJS(String js) {
        synchronized(LOCK) {
            if (mPendingJS == null) {
                mPendingJS = new StringBuilder();
                mPendingJS.append("javascript: ");
            }
            mPendingJS
                .append(js)
                .append("; ");
        }
    }
    

    Instead of calling loadUrl() call that method. (For making this simple I used a synchronized block, but this might be better suited to a different route. Since javascript runs on its own thread, this will need to be thread safe in some way or another).

    Then your WebView would have an interface like this:

    public class JSInterface {
    
        public String getPendingJS() {
            synchronized(LOCK) {
                String pendingCommands = mPendingJS.toString();
                mPendingJS.setLength(0);
                mPendingJS.append("javascript: ");
                return pendingCommands;
            }
        }
    
    }
    

    That returns a String with the pending commands and clears them so they don’t get returned again.

    You would add it to the WebView like this:

    mWebView.addJavascriptInterface(new JSInterface(), "JSInterface");

    Then in your javascript you would set some interval in which to flush the pending commands. On each interval it would call JSInterface.getPendingJS() which would return a String of all of the pending commands and then you could execute them.

    You could further improve this by adding a check in the execJS method to see if a EditText field exists in the WebView and is in focus. If there is one, then you would use this queueing method, but if there wasn’t one in focus then you could just call loadUrl() like normal. That way it only uses this workaround when it actually needs to.

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

Sidebar

Related Questions

Javascript (ECMAscript) supports the Array.prototype.forEach method since version 1.6 (ECMAscript edition 3, 2005). So
Since Amazon offers a great way to run static sites off S3. I am
Since there is no way to join tables using Google App Engine datastore, I
Since there is no way that you can make the flash object transparent, there
Since now I have only used plugin for editing and the way I use
I am investigating since a few hours the best way to use the Email
Since ldd lists only the dynamic libraries, is there a way to extract the
Is there any way to get the # of months and years since a
I'm using Python since some times and I am discovering the pythonic way to
So since System.Web & HttpContext isn't available in Silverlight is there a way to

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.