I am developing an app where i need to send one method request from javascript to android native and need to implement the code in native side. My javascript file consisits of.
function _CBSubscribeForNative( eventName, Message, Data ) {
try {
Android.CallFromJavaScript(eventName,Message.data);
}//...
In Main.java file i am using the following code.
{
WebView wv = (WebView) findViewById(R.id.webView1);
WebSettings webset = wv.getSettings();
webset.setJavaScriptEnabled(true);
wv.loadUrl("file:///android_asset/DocApt/DocApt/DocAptApp/72/index.html");
wv.addJavascriptInterface(new AndroidBridge(), "Android");
}//oncreate
private class AndroidBridge {
@SuppressWarnings("unused")
public void CallFromJavaScript(final String arg , final String arg1) {
System.out.println("222222222");
handler.post(new Runnable() {
public void run() {
String requestfrmjs = arg.toString();
Toast.makeText(getApplicationContext(), "received request is " + requestfrmjs, Toast.LENGTH_SHORT).show();
}
});
}
}
As per my code i am unable to get toast. Is there anything went wrong with my code.
can anyone please help me with this..