fixed potential NPEs in ShareWithActivity
This commit is contained in:
parent
777e060100
commit
4b0043ba91
|
@ -134,11 +134,12 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
final String type = getIntent().getType();
|
final String type = getIntent().getType();
|
||||||
if (type != null && !type.startsWith("text/")) {
|
final Uri uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
this.share.uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
if (type != null && uri != null && !type.startsWith("text/")) {
|
||||||
|
this.share.uri = uri;
|
||||||
try {
|
try {
|
||||||
this.share.image = type.startsWith("image/")
|
String guess = URLConnection.guessContentTypeFromName(uri.toString());
|
||||||
|| URLConnection.guessContentTypeFromName(this.share.uri.toString()).startsWith("image/");
|
this.share.image = type.startsWith("image/") || (guess != null && guess.startsWith("image/"));
|
||||||
} catch (final StringIndexOutOfBoundsException ignored) {
|
} catch (final StringIndexOutOfBoundsException ignored) {
|
||||||
this.share.image = false;
|
this.share.image = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue