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

  • Home
  • SEARCH
  • 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 7777811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:14:15+00:00 2026-06-01T18:14:15+00:00

I am trying to pass JSON-formatted data from my Android WebView to a HTML

  • 0

I am trying to pass JSON-formatted data from my Android WebView to a HTML page. However, the app crashes whenever I try to parse the original JSON data, which I am expecting to be of the format {"key":"data"}

The aim of my app will be to interpret this JSON data, form it into an array of values, and send it to a HTML page. Is this the correct approach to take?

Here is my WebView code…

public class MyWebView extends Activity {
    WebView mWebView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.web_view);

        mWebView = (WebView) findViewById(R.id.webviewSch);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.addJavascriptInterface(this, "webConnector");
        mWebView.loadUrl("file:///android_asset/table.html");
    }

    public String load() {
        return "{\"key\":\"data\"}";
    }
}

And here is the HTML code…

<html>
<head>
<title>Test</title>
<script type="text/javascript">

function loader() {
    var jsonData = window.webConnector.load();
}

</script>
</head>
<body onload="loader()">
Do nothing
</body>
</html> 

Here is the log cat:

04-15 00:35:44.551: W/dalvikvm(442): JNI WARNING: jarray 0x4053f1a0 points to non-array object (Ljava/lang/String;)
04-15 00:35:44.551: I/dalvikvm(442): "WebViewCoreThread" prio=5 tid=9 NATIVE
04-15 00:35:44.551: I/dalvikvm(442):   | group="main" sCount=0 dsCount=0 obj=0x4051bcc0 self=0x19b200
04-15 00:35:44.551: I/dalvikvm(442):   | sysTid=451 nice=0 sched=0/0 cgrp=default handle=1684280
04-15 00:35:44.551: I/dalvikvm(442):   | schedstat=( 206004592 365607782 69 )
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.LoadListener.nativeFinished(Native Method)
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.LoadListener.nativeFinished(Native Method)
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.LoadListener.tearDown(LoadListener.java:1200)
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.LoadListener.handleEndData(LoadListener.java:721)
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.LoadListener.handleMessage(LoadListener.java:219)
04-15 00:35:44.551: I/dalvikvm(442):   at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 00:35:44.551: I/dalvikvm(442):   at android.os.Looper.loop(Looper.java:130)
04-15 00:35:44.551: I/dalvikvm(442):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
04-15 00:35:44.551: I/dalvikvm(442):   at java.lang.Thread.run(Thread.java:1019)
04-15 00:35:44.551: E/dalvikvm(442): VM aborting
  • 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-01T18:14:16+00:00Added an answer on June 1, 2026 at 6:14 pm

    I copy pasted your code and it works (nothing is shown because you dont show the data) but the callback made from the Javascript into Android is executed correctly. You can check it with this code:

        WebView mWebView = (WebView) findViewById(R.id.webView1);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.addJavascriptInterface(this, "webConnector");
        mWebView.addJavascriptInterface(this, "toaster");
        mWebView.loadUrl("file:///android_asset/table.html");
        }
    
        public String load() {
            Log.e("HelloJavascript","HelloJavascript");
            return "{\"key\":\"data\"}";
        }
    
        public void print(String message){
            Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
        }
    

    And the HTML

        <html>
        <head>
        <title>Test</title>
        <script type="text/javascript">
    
        function loader() {
            var jsonData = window.webConnector.load();
            toaster.print(jsonData);
        }
    
        </script>
        </head>
        <body onload="loader()">
        Do nothing
        </body>
        </html> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass JSON data from the client browser to an ASP.NET
i'm trying to pass some JSON data encrypted to my app but seem when
I am trying to pass a json data as param for cURL POST. However,
I am a little new to android/java. I am trying to pass JSON values
I'm trying to pass an image from Android to WCF REST service as part
I'm trying to pass some lat/long values from a JSON doc to iPhone's Map
How can javascript pass data, for example from an HTML table, without using AJAX?
I am currently trying to pass a generated JSON string to dojo for parsing
I'm trying to pass Json to my View using ViewData Controller ViewData(JsonRegionList) = Json(RegionService.GetActiveRegions())
I’m trying to pass a JSON object to Enyo using a web server. The

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.