0

I am new to java script using in android,I have function in js file to convert user name,how to send i/p values to this and how to retrieve data for this file in android activity button click.if any one have idea please tell me thanks in advance.

1
  • Have you used webview? Commented Feb 6, 2013 at 10:18

1 Answer 1

1

tru out this :

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

web = (WebView) findViewById(R.id.webview1);



web.setWebChromeClient(new MyWebChromeClient());

web.addJavascriptInterface(new DemoJavaScriptInterface(), "temp_1");

web.loadUrl("file:///android_asset/temp_1.html");

}   
}

final class DemoJavaScriptInterface {

private Handler mHandler = new Handler();
WebView web;
DemoJavaScriptInterface() {
}

public void clickOnAndroid() {
mHandler.post(new Runnable() {
    public void run() {
        web.loadUrl("javascript:init();");
      }
});

} }

final class MyWebChromeClient extends WebChromeClient {

private static final String LOG_TAG = "WebViewDemo";
@Override

public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
    Log.e(LOG_TAG, message);
    result.confirm();
    return true;
}
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.