title: Workaround for file uploads on Android 4.4 using reflection
body: <p>From Android 4.1 to Android 4.3, you could subclass <code>WebChromeClient</code> on Android and implement the following (hidden, thus no <code>@Override</code>) method:</p>
  
  <pre><code>public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType, String capture) { ... }
  </code></pre>
  
  <p>You would open a file picker in that method, and when your <code>Activity</code> receives the result in <code>onActivityResult(...)</code>, just call the single method that is available on the <code>ValueCallback&lt;Uri&gt;</code> instance with the file URI. That's it.</p>
  
  <p>Unfortunately, this method was removed from the API in Android 4.4 and is not being called anymore.</p>
  
  <p>Is there <em>any</em> way you can work around this, e.g. with reflection?</p>
  
  <p>I mean, you could set an <code>onclick="..."</code> listener on the <code>&lt;input type="file"&gt;</code> element in HTML, which would still be called.</p>
  
  <p>After intercepting the <code>onclick="..."</code> callback in Java (maybe via <code>addJavascriptInterface(...)</code>) you could open a file picker as usual. But the problem is that there's no <code>ValueCallback&lt;Uri&gt;</code> instance available that you could send your result (the file that was picked) to.</p>
  
  <p>Setting the <code>value="..."</code> of the <code>&lt;input type="file"&gt;</code> in HTML manually is not possible, either, because it's read-only. But the <code>WebView</code> implementation itself can certainly write the value, obviously. So could you use reflection to set the value there or find another workaround?</p>
  
  <p>I'm searching for a cleaner and more comfortable solution than detecting the <code>&lt;input type="file"&gt;</code> click (e.g. via its <code>onclick="..."</code> listener) and doing the file selection and file upload manually from Java. Enabling file uploads <em>in the WebView</em>, as they should work, would be cleaner, certainly.</p>