title: Android Webview EvaluateJavascript sometimes does not return a response
body: <p>I have been trying to fix this for weeks and have no clue what is causing the issue. In my project I am utilizing the Android Webview's <code>evaluateJavascript()</code> method like this:</p>
  
  <pre><code>    this.runOnUiThread(new Runnable() {
          @Override
          public void run() {
              webView.evaluateJavascript(command, new ValueCallback&lt;String&gt;() {
                  @Override
                  public void onReceiveValue(String value) {
                      //Parsing and taking action here
                      Log.d("Response", value);
                  }
              });
          }
      });
  </code></pre>
  
  <p>A sample string of the javascript I am sending would be:</p>
  
  <pre><code>document.getElementById("message").value="Stuff worked!"; 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>document.getElementById("some-awesome-button").click(); 
  </code></pre>
  
  <p>While 9 times out of 10 these calls return a value in the <code>onReceiveValue()</code> method, once in a while I just straight never receive a response at all. </p>
  
  <p>This lack of a response has made chaining events a nightmare and I have no clue why this would be happening. </p>
  
  <p>Some more data to head off any additional questions:</p>
  
  <ul>
  <li>The minimum SDK for this project is 21 and I am targeting 28.</li>
  <li>I am <strong>not</strong> utilizing any <code>javascriptInterface</code>s at this point in time and don't intend to for this project for a few business-related reasons. </li>
  <li>When I do get a response fro the webview in the <code>onReceiveValue()</code> method it is usually the value I had just set or 'null' if it was a click event. Regardless, the issue isn't that I am sometimes receiving nulls or other values, but the distinct lack of a response <em>sometimes</em>. </li>
  <li>As shown in the code sample, I am definitely running this on the UI Thread as per the documentation. </li>
  <li>I had the server dev add in some code to console log whenever I am hitting the button and when I get back a successful value in the <code>onReceiveValue()</code> method the console logs are working and responding but when I am in the situation where I do not get back a response, the web console logs never fire and it never detects an interaction with the button.</li>
  <li>I have also tried adding in a timer with logic that listens for a response from the webview and if it does not receive it, attempts to make the same call again up to 10x. When the first call fails, none of the subsequent attempts work.</li>
  <li>These are the settings for my webview:</li>
  </ul>
  
  <pre><code>    webView.getSettings().setJavaScriptEnabled(true);
      webView.getSettings().setDomStorageEnabled(true);
      webView.getSettings().setAllowFileAccess(true);
  </code></pre>
  
  <p>It almost seems like the issue is with the Javascript Bridge but I cannot be certain. </p>
  
  <p>The summary question I have is, <strong>what could cause the Android WebView's <code>evaluateJavascript()</code> call to not trigger a callback nor return a value in the <code>onReceiveValue()</code> method?</strong></p>