Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created April 16, 2017 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/a9fea7b45716c1a2ad7cd3d81d9e8e7d to your computer and use it in GitHub Desktop.
Save jfversluis/a9fea7b45716c1a2ad7cd3d81d9e8e7d to your computer and use it in GitHub Desktop.
Inheritance of the WebChromeClient to intercept the FileChooser event
public class FileChooserWebChromeClient : WebChromeClient
{
private Action<IValueCallback, Java.Lang.String, Java.Lang.String> callback;
public FileChooserWebChromeClient (Action<IValueCallback, Java.Lang.String, Java.Lang.String> callback)
{
callback = callback;
}
// For Android < 5.0
[Java.Interop.Export]
public void openFileChooser (IValueCallback uploadMsg, Java.Lang.String acceptType, Java.Lang.String capture)
{
callback (uploadMsg, acceptType, capture);
}
// For Android > 5.0
public override Boolean OnShowFileChooser (Android.Webkit.WebView webView, IValueCallback uploadMsg, WebChromeClient.FileChooserParams fileChooserParams)
{
try {
callback (uploadMsg, null, null);
} catch (Exception) {
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment