diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2022-04-27 16:11:10 +0200 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2022-04-27 16:12:33 +0200 |
commit | 5924e2b90e52b366813e985b6bcf28129b0f8f60 (patch) | |
tree | e86c7cf5271d524f3435eb3bd7b8e59921ca65e3 /platform | |
parent | 504708ae21b9722ddbf33a2d557a6a9ed0d70855 (diff) |
Check for null when retrieving clip data item text on Android
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/Godot.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 6e597163ab..de69441e48 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -663,14 +663,13 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC } public String getClipboard() { - String copiedText = ""; - - if (mClipboard.hasPrimaryClip()) { - ClipData.Item item = mClipboard.getPrimaryClip().getItemAt(0); - copiedText = item.getText().toString(); - } - - return copiedText; + ClipData clipData = mClipboard.getPrimaryClip(); + if (clipData == null) + return ""; + CharSequence text = clipData.getItemAt(0).getText(); + if (text == null) + return ""; + return text.toString(); } public void setClipboard(String p_text) { |