protected bool ChooseFile(IValueCallback filePathCallback, Intent intent, string title)
        {
            if (_activity == null)
            {
                return(false);
            }

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

                Object result = ParseResult(resultCode, intentData);
                filePathCallback.OnReceiveValue(result);
            };

            _requestCodes = _requestCodes ?? new List <int>();

            int newRequestCode = ActivityResultCallbackRegistry.RegisterActivityResultCallback(callback);

            _requestCodes.Add(newRequestCode);

            _activity.StartActivityForResult(Intent.CreateChooser(intent, title), newRequestCode);

            return(true);
        }
Exemple #2
0
        public void UnregisterCallbacks()
        {
            if (_requestCodes == null || _requestCodes.Count == 0 || _activity == null)
            {
                return;
            }

            foreach (int requestCode in _requestCodes)
            {
                ActivityResultCallbackRegistry.UnregisterActivityResultCallback(requestCode);
            }

            _requestCodes = null;
        }
Exemple #3
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     ActivityResultCallbackRegistry.InvokeCallback(requestCode, resultCode, data);
 }