0

I'm writing an Android app with Xamarin and F# and need to use the ClipboardManager to copy some text to the clipboard. In Java the best way to do so is this:

android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 
android.content.ClipData clip = android.content.ClipData.newPlainText("text label","text to clip");
clipboard.setPrimaryClip(clip);

What's the best way to express this code in F#?

Thank you!

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Ilya S.
  • 11
  • 2

1 Answers1

0

I think I've found the solution:

use clipboard = this.GetSystemService(Context.ClipboardService) :?> Android.Content.ClipboardManager
use clip = Android.Content.ClipData.NewPlainText("textlabel", "text to clip")
clipboard.PrimaryClip <- clip

where this refers to an Activity

Ilya S.
  • 11
  • 2