aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/ClipboardUtils.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-10-09 18:17:52 +0200
committerSamuel Tardieu <sam@rfc1149.net>2014-10-09 18:19:01 +0200
commit24c17c066c297aa3a1fd3091245e8f70b73fc81b (patch)
tree78ac5324888659bcd915b97fa6a5fd16502cf26d /main/src/cgeo/geocaching/utils/ClipboardUtils.java
parentca5bd8f480c09ab7cbb6afd1059d0e8f0a8d1c89 (diff)
downloadcgeo-24c17c066c297aa3a1fd3091245e8f70b73fc81b.zip
cgeo-24c17c066c297aa3a1fd3091245e8f70b73fc81b.tar.gz
cgeo-24c17c066c297aa3a1fd3091245e8f70b73fc81b.tar.bz2
fix #4409: NPE when trying to edit WP coordinates
Some clipboard data cannot be coerced to text, including an empty clipboard.
Diffstat (limited to 'main/src/cgeo/geocaching/utils/ClipboardUtils.java')
-rw-r--r--main/src/cgeo/geocaching/utils/ClipboardUtils.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/utils/ClipboardUtils.java b/main/src/cgeo/geocaching/utils/ClipboardUtils.java
index 6be5b7f..fb30886 100644
--- a/main/src/cgeo/geocaching/utils/ClipboardUtils.java
+++ b/main/src/cgeo/geocaching/utils/ClipboardUtils.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.utils;
import cgeo.geocaching.CgeoApplication;
+import org.eclipse.jdt.annotation.Nullable;
+
import android.content.Context;
/**
@@ -33,10 +35,12 @@ public final class ClipboardUtils {
*
*/
@SuppressWarnings("deprecation")
+ @Nullable
public static String getText() {
// fully qualified name used here to avoid buggy deprecation warning (of javac) on the import statement
final android.text.ClipboardManager clipboard = (android.text.ClipboardManager) CgeoApplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
- return clipboard.getText().toString();
+ final CharSequence text = clipboard.getText();
+ return text != null ? text.toString() : null;
}
}