Skip to content

Commit

Permalink
Do not fail with NPE when scheme is null
Browse files Browse the repository at this point in the history
Also remove some debug logging left by mistake.
  • Loading branch information
fornwall committed Mar 23, 2016
1 parent 3aaa0ab commit 421dfcc
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ protected void onResume() {
final String type = intent.getType();
final String scheme = intent.getScheme();

if (intent.getExtras() == null) {
Log.e("termux", "NULL EXTRAS");
} else {
for (String key : intent.getExtras().keySet()) {
Object value = intent.getExtras().get(key);
Log.d("termux", String.format("Extra %s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}

if (Intent.ACTION_SEND.equals(action) && type != null) {
final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
final Uri sharedUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
Expand All @@ -74,9 +64,9 @@ protected void onResume() {
} else {
showErrorDialogAndQuit("Send action without content - nothing to save.");
}
} else if (scheme.equals("content")) {
} else if ("content".equals(scheme)) {
handleContentUri(intent.getData(), intent.getStringExtra(Intent.EXTRA_TITLE));
} else if (scheme.equals("file")) {
} else if ("file".equals(scheme)) {
// When e.g. clicking on a downloaded apk:
String path = intent.getData().getPath();
File file = new File(path);
Expand All @@ -87,7 +77,7 @@ protected void onResume() {
showErrorDialogAndQuit("Cannot open file: " + e.getMessage() + ".");
}
} else {
showErrorDialogAndQuit("Unhandled scheme: " + intent.getScheme() + ".");
showErrorDialogAndQuit("Unable to receive any file or URL.");
}
}

Expand Down

0 comments on commit 421dfcc

Please sign in to comment.