private void RegisterCustomFileUploadActivity(IValueCallback filePathCallback, Intent chooserIntent, string title = "File upload")
        {
            if (Forms.Context is IFormsWebViewMainActivity)
            {
                var appActivity = Forms.Context as IFormsWebViewMainActivity;

                Action <Result, Intent> callback = (resultCode, intentData) =>
                {
                    Console.WriteLine("RegisterCustomFileUploadActivity: Entrato in callback");
                    if (filePathCallback == null)
                    {
                        return;
                    }

                    var result = FileChooserParams.ParseResult((int)resultCode, intentData);
                    filePathCallback.OnReceiveValue(result);
                    Console.WriteLine("RegisterCustomFileUploadActivity: Processato evento callback");
                    appActivity.UnregisterActivityResultCallback(FILECHOOSER_RESULTCODE);
                };

                appActivity.RegisterActivityResultCallback(FILECHOOSER_RESULTCODE, callback);

                ((FormsAppCompatActivity)Forms.Context).StartActivityForResult(Intent.CreateChooser(chooserIntent, title), FILECHOOSER_RESULTCODE);
                Console.WriteLine("RegisterCustomFileUploadActivity: REGISTRATO");
            }
            else
            {
                Console.WriteLine("RegisterCustomFileUploadActivity: Non registrato");
            }
        }
예제 #2
0
            private async Task StartFileChooser(CancellationToken ct, FileChooserParams fileChooserParams)
            {
                var intent = fileChooserParams.CreateIntent();
                //Get an invisible (Transparent) Activity to handle the Intent
                var delegateActivity = await StartActivity <DelegateActivity>(ct);

                var result = await delegateActivity.GetActivityResult(ct, intent);

                _filePathCallback.OnReceiveValue(FileChooserParams.ParseResult((int)result.ResultCode, result.Intent));
            }
        private void RegisterCustomFileUploadActivity(IValueCallback filePathCallback, Intent chooserIntent, string title = "File Chooser")
        {
            if (Forms.Context is IFormsWebViewMainActivity)
            {
                var appActivity = Forms.Context as IFormsWebViewMainActivity;

                Action<Result, Intent> callback = (resultCode, intentData) =>
                {
                    if (filePathCallback == null)
                        return;

                    var result = FileChooserParams.ParseResult((int)resultCode, intentData);
                    filePathCallback.OnReceiveValue(result);

                    appActivity.UnregisterActivityResultCallback(FILECHOOSER_RESULTCODE);
                };

                appActivity.RegisterActivityResultCallback(FILECHOOSER_RESULTCODE, callback);

                ((FormsAppCompatActivity)Forms.Context).StartActivityForResult(Intent.CreateChooser(chooserIntent, title), FILECHOOSER_RESULTCODE);
            }
        }
예제 #4
0
 protected virtual Object ParseResult(Result resultCode, Intent data)
 {
     return(FileChooserParams.ParseResult((int)resultCode, data));
 }
예제 #5
0
 protected static Android.Net.Uri[] ParseResult(Result resultCode, Intent data)
 {
     return(FileChooserParams.ParseResult((int)resultCode, data));
 }