0

I have seen several questions similar to mine, but none seem to quite answer my question.

I have some javascript in my assets folder, and i want to use a WebView (or any other way that works) to bind a java object to it so that my server can send updates to my js, and then have my js call my java object.

I have tried loadUrl() and loadDataWithBaseURL() and neither seem to work, I use the getURL() after setting it to check it and it always returns null. After looking at the other questions, I can tell I'm referencing the path correctly (or at least the same as them).

I should note that it is a .js file, not an html file with js in it. However, I haven't seen anything saying that doesn't work / I shouldn't do that.

Here is my code to set it:

    interacter = (WebView) findViewById(R.id.interact);
    interacter.getSettings().setJavaScriptEnabled(true);
    interacter.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    interacter.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    interacter.setClickable(true);
    interacter.addJavascriptInterface(game, "Android");
    //loadDataWithBaseURL was here
    Log.i("Path is", interacter.getUrl() +" ");

Am I doing something wrong, is there a better way to do it, does this even work?

EDIT

I noticed used the loadDataWithBaseURL() wrong (the commented line in my code was where it was), and I am looking into that at the moment. Help on this still appreciated

Ben Roby G
  • 118
  • 9

0 Answers0