Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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