public static Task RequestAsync(ShareTextRequest request) { var items = new List <string>(); if (!string.IsNullOrWhiteSpace(request.Text)) { items.Add(request.Text); } if (!string.IsNullOrWhiteSpace(request.Uri)) { items.Add(request.Uri); } var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, string.Join(Environment.NewLine, items)); if (!string.IsNullOrWhiteSpace(request.Subject)) { intent.PutExtra(Intent.ExtraSubject, request.Subject); } var chooserIntent = Intent.CreateChooser(intent, request.Title ?? string.Empty); chooserIntent.SetFlags(ActivityFlags.ClearTop); chooserIntent.SetFlags(ActivityFlags.NewTask); Platform.CurrentContext.StartActivity(chooserIntent); return(Task.CompletedTask); }
public static Task RequestAsync(ShareTextRequest request) { var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += ShareTextHandler; DataTransferManager.ShowShareUI(); void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e) { var newRequest = e.Request; newRequest.Data.Properties.Title = request.Title ?? AppInfo.Name; if (!string.IsNullOrWhiteSpace(request.Text)) { newRequest.Data.SetText(request.Text); } if (!string.IsNullOrWhiteSpace(request.Uri)) { newRequest.Data.SetWebLink(new Uri(request.Uri)); } dataTransferManager.DataRequested -= ShareTextHandler; } return(Task.CompletedTask); }
public static Task RequestAsync(ShareTextRequest request) { var items = new List <NSObject>(); if (!string.IsNullOrWhiteSpace(request.Text)) { items.Add(new ShareActivityItemSource(new NSString(request.Text), request.Title)); } if (!string.IsNullOrWhiteSpace(request.Uri)) { items.Add(new ShareActivityItemSource(NSUrl.FromString(request.Uri), request.Title)); } var activityController = new UIActivityViewController(items.ToArray(), null); var vc = Platform.GetCurrentViewController(); if (activityController.PopoverPresentationController != null) { activityController.PopoverPresentationController.SourceView = vc.View; } return(vc.PresentViewControllerAsync(activityController, true)); }
public static Task RequestAsync(ShareTextRequest request) => throw new NotImplementedInReferenceAssemblyException();