PrimaryClip is present, but text is empty on Galaxy S5

I'm trying to access the clipboard, and while it works correctly on other phones I've tested, Galaxy S5 returns an empty string. Is there a workaround for this?

The way I access the text is like this:

ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null && clipboard.hasPrimaryClip()) {
    ClipData clip = clipboard.getPrimaryClip();
    String text = clip.getItemAt(0).getText().toString();
    // Handle the text here
}

The thing is, hasPrimaryClip() returns true, and getPrimaryClip() returns a non-null item. The code runs well, but text ends up being an empty string only on Galaxy S5.