Android Clipboard crash

Hi folks!

I’ve seen a crash in this code:

    public final String getClipboardContent()
        ClipboardManager clipboard = (ClipboardManager) getSystemService (CLIPBOARD_SERVICE);
        return clipboard.getText().toString();

The error is:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference

If interested, I pick this up with HockeyApp, which we use for all our app variants.

Anyhow - looks like you need to defend against this, because…

… says that getText can return null.

This crash happened on a Samung SM-G930V device running Android 7.0, if that helps.

Thanks in advance!


Thanks for reporting this, the fix will appear shortly.

The fix is on develop. You will need to re-save your project in Projucer.