public void ImageFromUri(Uri uri) { var uriTool = new UriTool(); ImagePath = uriTool.GetActualPathFromFile(uri); ItemsReceivedEvent?.Invoke(this, EventArgs.Empty); }
public void OnReceive(Context context, Intent intent) { if (intent.Action == null) { return; } Log.Debug($"Received an event: {intent}"); if (intent.Action.Equals(Intent.ActionSend)) { //TODO: Sharing got broken when implementing image picker. Log.Debug("Action directed to ACTION_SEND"); var uri = (Android.Net.Uri)intent.GetParcelableExtra(Intent.ExtraStream); var uriTool = new UriTool(); ImagePath = uriTool.GetActualPathFromFile(uri); Toast.MakeText(context, "Image Received", ToastLength.Short).Show(); while (ContextCompat.CheckSelfPermission(MainActivity.Instance, Manifest.Permission.ReadExternalStorage) != Permission.Granted) { ActivityCompat.RequestPermissions(MainActivity.Instance, new String[] { Manifest.Permission.ReadExternalStorage }, 1); Task.Delay(TimeSpan.FromSeconds(1.5)).Wait(); } ItemsReceivedEvent?.Invoke(this, EventArgs.Empty); } else if (intent.Action.Equals(Intent.ActionSendMultiple)) { Log.Debug("Multiple pictures received!"); ItemsReceivedEvent?.Invoke(this, EventArgs.Empty); } }