title: Call javascript function in Android WebView
body: <p>I have an activity with WebView and Button on it. Android sdk 17. Website isn't mine, so I can't change it anyway. I need to do js code by android button click.</p>
  
  <p>I'm trying to do this </p>
  
  <pre><code>public class RostelecomLoginActivity extends Activity {
  
  WebView webView;
  String url;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_rostelecom_login);
  
      Intent webIntent = getIntent();
      final String url = webIntent.getStringExtra("url");
  
      webView = (WebView) findViewById(R.id.webView1);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.getSettings().setSaveFormData(true);
      webView.getSettings().setSavePassword(true);
  
      Button button = (Button) findViewById(R.id.button1);
          button.setOnClickListener(new OnClickListener() {
  
          public void onClick(View v) {
              webView.addJavascriptInterface(new Object(){
                  @JavascriptInterface
                  public void test(){
                      Log.d("JS", "test");
                  }
              },"Android");
              webView.loadUrl("javascript:(function(){document.getElementById('mA').click();})()");
          }
      });
  
      webView.loadUrl(url);
  
  }}
  </code></pre>
  
  <p>But it doesn't do anything.
  How can I call my js right?</p>