```
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;
    }
}

```