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…
https://developer.android.com/reference/android/text/ClipboardManager
… 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!
Pete