diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-06 18:25:31 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-06 18:25:31 +0100 |
commit | 4b0043ba91026887d74bfc46f0bcb0b23a6c2230 (patch) | |
tree | d3c7c63f07655e468b1e960b1767e0f8da97739f | |
parent | 777e060100c724da54e5ec4fef15f5c66c271b5e (diff) |
fixed potential NPEs in ShareWithActivity
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 5e770376b..a3904d21d 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -134,11 +134,12 @@ public class ShareWithActivity extends XmppActivity { @Override public void onStart() { final String type = getIntent().getType(); - if (type != null && !type.startsWith("text/")) { - this.share.uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + final Uri uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + if (type != null && uri != null && !type.startsWith("text/")) { + this.share.uri = uri; try { - this.share.image = type.startsWith("image/") - || URLConnection.guessContentTypeFromName(this.share.uri.toString()).startsWith("image/"); + String guess = URLConnection.guessContentTypeFromName(uri.toString()); + this.share.image = type.startsWith("image/") || (guess != null && guess.startsWith("image/")); } catch (final StringIndexOutOfBoundsException ignored) { this.share.image = false; } |