To ensure that the clipboard has the right content you could use this code to paste.
import android.content.ClipDescription;
// Paste string from clipboard
if (clipboard.hasPrimaryClip()) {
android.content.ClipDescription description = clipboard.getPrimaryClipDescription();
android.content.ClipData data = clipboard.getPrimaryClip();
if (data != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
String str_paste = String.valueOf(data.getItemAt(0).getText());
text(str_paste, width/2, height/2);
}
}