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

The Archive Base Latest Questions

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

Ok guys. What I’m trying to do: I’ve got some backend code written in

  • 0

Ok guys. What I’m trying to do: I’ve got some backend code written in javascript (the project was originally supposed to be a web-app) and I’ve added a javascript interface to my android web view, and when I press a button in my ui, the javascript code does some stuff, then calls a function in my javascript interface when it is done… The code from my javascript interface:

public void onReady() {
    backend.loadUrl("javascript:dokus.backend.onLoginStatusChange(Bridge.onLoginStatusChange);");
    backend.loadUrl("javascript:dokus.backend.onProjectsChange(Bridge.onProjectsChange);");
    backend.loadUrl("javascript:dokus.backend.onLatestEntriesChange(Bridge.onLatestEntriesChange);");
}

public void onLoginStatusChange (boolean loggedIn, String error) {
    Toast.makeText(mainActivity, "LoginStatusChange", Toast.LENGTH_SHORT).show();
}
...

I’ve already verified that the onReady function is called, so that’s not the problem.
The javascript function which calls onLoginStatusChange is this following:

function _login_callback(loggedIn, msg) {
    if (loggedIn) {
        _get_projects();
        _get_latest_entries();
    }

    console.log(_login_status_changed_callback);

    if (_login_status_changed_callback !== undefined)
        _login_status_changed_callback (loggedIn, msg);
}

The error i get is this: “Line: 180, type error”. That’s all i get from my WebChromeView function, that prints everything from console.log() to a toast message.

the console.log(_login_status_changed_callback) prints out the following:

function onLoginStatusChange () {
   [native code]
}

I’ve verified that the correct arguments are called to the function (a bool and a string), so that shouldn’t be the error either… I’m at a loss, what do i do?

setup code for the web view:

private void setupBackend () {
    final DokusActivity that = this;

    backend = new WebView(this);
    BackendBridge.getInstance().initInstance(this, backend);

    backend.getSettings().setJavaScriptEnabled(true);
    backend.getSettings().setDomStorageEnabled(true);
    backend.addJavascriptInterface(BackendBridge.getInstance(), "Bridge");

    backend.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(that, "Oh no! " + description, Toast.LENGTH_SHORT).show();
        }
    });

    backend.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage (ConsoleMessage consoleMessage) {
            Toast.makeText(that, "Oh no! " + consoleMessage.lineNumber() + ": " + consoleMessage.message(), Toast.LENGTH_SHORT).show();
            return false;
        }
    });

    backend.loadUrl("file:///android_asset/index.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-30T09:20:23+00:00Added an answer on May 30, 2026 at 9:20 am

    Apparently, the webview has issues when you try to pass native functions as callbacks to other methods. What I did was create a new .js file which works as callbacks, all the js callbacks do, is calling the native method.

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

Sidebar

Related Questions

Guys, I’ve been writing code for 15+ years, but managed to avoid Web Development
guys I want to start programing with C++. I have written some programs in
Guys; How are you doing today? I have to create a dll project on
guys. I have UITableView with different cells and I have code, which counts height.
guys. I have two view controllers with two uiwebviews. Here is my code: First
Guys that is code copied from a book (Programming Windows 5th edition): #include <windows.h>
Guys, I'm trying to write xpath or css to find/click on list element All
guys, I'm trying to realize viewing comments on internet portal and I'm using UITableView.
guys, I have iOS app, which running good on ios5.0, but on 4.3.3 it's
guys i got a php file that use it as xml for a flash

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.