public static void SetClipboardText(Context context, string text) { Handler handler = new Handler(Looper.MainLooper); handler.Post(() => { ClipboardManager clipboard = (ClipboardManager)context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(text, text); clipboard.PrimaryClip = clip; }); ToastHelper.ShowToast(context, "Text copied to clipboard.", ToastLength.Long); }
private static void OpenFile(Context context, Android.Net.Uri file, string mimeType) { try { Intent i = new Intent(Intent.ActionView); i.SetDataAndType(file, mimeType); i.AddFlags(ActivityFlags.GrantReadUriPermission); i.AddFlags(ActivityFlags.NewTask); // ? context.StartActivity(i); } catch (Exception ex) { ToastHelper.ShowToast(context, "Cannot open file.", ToastLength.Long); Log.Debug(TAG, "Cannot open file: " + ex.ToString()); } }
private async static void TextReceiver_TextReceiveFinished(TextTransfer.TextReceiveEventArgs e) { try { Activity.Invoke(); if (!e.Success) { ToastHelper.ShowToast(context, "Failed to receive text.", ToastLength.Long); return; } await ClipboardHelper.CopyTextToClipboard(context, (Guid)e.Guid); Finish?.Invoke(); } finally { await progressNotifier?.ClearProgressNotification(); } }