Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created April 16, 2017 11:29
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/b3b644e4a95f5ee9417bcb7bfebee453 to your computer and use it in GitHub Desktop.
Save jfversluis/b3b644e4a95f5ee9417bcb7bfebee453 to your computer and use it in GitHub Desktop.
OnActivityResult on the MainActivity for enabling camera in file upload control
public class MainActivity : FormsAppCompatActivity
{
public static IValueCallback UploadMessage;
private static int FILECHOOSER_RESULTCODE = 1;
public static Android.Net.Uri mCapturedImageURI;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Uncomment to enable debugging of the webview on a desktop
//Android.Webkit.WebView.SetWebContentsDebuggingEnabled(true);
Forms.Init (this, bundle);
LoadApplication (new App ());
}
protected override void OnActivityResult (int requestCode, Result resultCode, Android.Content.Intent data)
{
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == UploadMessage)
return;
Java.Lang.Object result = data == null ? mCapturedImageURI : data.Data;
UploadMessage.OnReceiveValue (new Android.Net.Uri [] { (Android.Net.Uri)result });
UploadMessage = null;
} else
base.OnActivityResult (requestCode, resultCode, data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment