1

I'm a bit lost here... I've been looking online and I haven't found anything like what I'm looking for. This is what I'm doing in java

ClsAccessor accessors = new ClsAccessor();



class ClsAccessor{
    public String WorkingWithJason(String Json){
        String JsonVar;
        JsonVar ="";
        if (Json != ""){
            generateNoteOnSD("JsonFile.txt", Json);
        }
        JsonVar = getfileFromSDCard("JsonFile.txt");
        return JsonVar;
    }
    public void generateNoteOnSD(String Name, String data){
    //....
    }

    public String getfileFromSDCard(String Name){
    //....
    String data;
    //data = ".....";
    return data;
    }
}


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

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(accessors, "accessor");
    mWebView.loadUrl("file:///android_asset/Main.html");
    mWebView.setWebViewClient(new HelloWebViewClient());


}

and moreless this is what I need on javascript

var text = "";
function SendData(RecievedTextVariable){
    var text = accessor.WorkingWithJason(RecievedTextVariablejsn);  
    document//accessor.outWorkingWithJason(textjsn);  
    $("#main_div").html("bbbbbb bbbbbbbb"+text);
} 

Any ideas or any example?

1 Answer 1

2
mWebView.addJavascriptInterface(new YourInterface(), "something");

class YourInterface{
    public void out(String value){
        // do something
    }
}

Instead of document.out(text) use something.out(text).

Sign up to request clarification or add additional context in comments.

2 Comments

can i do a return in the method out and receive it in javascript??
Wouldn't it be much more fun if you try that by your self? If you have any problems just ask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.