Exemplo n.º 1
0
    static string?GetTextAndroid()
    {
        var context = Android.App.Application.Context;

        if (context is null)
        {
            return(null);
        }

        var clipboard = ClipboardManager.FromContext(context);

        return(clipboard?.Text);
    }
        static void SetTextAndroid(string text)
        {
            var context = Android.App.Application.Context;

            if (context is null)
            {
                throw new InvalidOperationException("Android context is null");
            }

            var clipboard = ClipboardManager.FromContext(context);

            if (clipboard is null)
            {
                throw new InvalidOperationException("ClipboardManager.FromContext is null");
            }

            clipboard.Text = text;
        }