Created
April 16, 2017 11:29
-
-
Save jfversluis/b3b644e4a95f5ee9417bcb7bfebee453 to your computer and use it in GitHub Desktop.
OnActivityResult on the MainActivity for enabling camera in file upload control
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 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