Created
April 16, 2017 11:21
-
-
Save jfversluis/a9fea7b45716c1a2ad7cd3d81d9e8e7d to your computer and use it in GitHub Desktop.
Inheritance of the WebChromeClient to intercept the FileChooser event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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