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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:57:45+00:00 2026-05-27T18:57:45+00:00

I am working on an android project right now and have a question about

  • 0

I am working on an android project right now and have a question about how to do callbacks in different webviews. I used JSInterface for my project too. Here I have 2 webviews. One has an index page, anther is a overlay(still a html page though.) What I want to do is if any user clicks on some links on the overlay, it should fire a callback function which is written in the java file where the index page was connected to through JSInterface. It might sound confusing, but I have draw something to help make it clear!

Thanks!enter image description here

  • 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-27T18:57:46+00:00Added an answer on May 27, 2026 at 6:57 pm

    You can use a custom URL scheme like myurl://function for your functionality links. Then write an event handler for the WebView’s shouldOverrideUrlLoading event in which you decide how to process the URL: either instruct the webview to load it, or do some custom action.

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)  
    {  
        if (url.startsWith("myurl://"))  
        {  
            // Parse further to extract function and do custom action  
        }
        else  
        {  
            // Load the page via the webview
            view.loadUrl(url);  
        }  
        return true;  
    }  
    

    I used startsWith to check the URL for this quick and dirty example, but you should consider using android.net.Uri.parse for parsing URLs.

    This should allow you to call the Java function foo() without having to go through the first WebView.

    If you want to go through the first webview, then you can call a function on the JSInterface like this (where webView1 is the first WebView retrieved through findViewById):

    webView1.loadUrl("javascript:myjsinterface.myjsfunc();")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a android project. I n that I have to deal
RESOLVED P.S.Because I don't have enough reputation to answer my own question right now
I am working on an Android project and have a problem with SQLite database
I am currently working on an android project. I am trying to have an
I am working on a project which includes an Android application which is used
I am working on a android project and I have my four tabs. On
I am currently working on an Android project where I'd have to use maven.
I am working with the sample Home application project on http://developer.android.com/resources/samples/Home/index.html I've added another
I have just begun working with the Android SDK and I am having problems
I am now working on changing android theme style at runtime, when the user

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.