Skip to content

Commit db8edd3

Browse files
committed
Fix SecurityException when opening downloaded files in other app
The flag was not passed to the intent that wraps the actual view intent for the app chooser.
1 parent 50e8189 commit db8edd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package us.shandian.giga.ui.adapter;
22

3+
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
34
import static android.content.Intent.FLAG_GRANT_PREFIX_URI_PERMISSION;
45
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
56
import static android.content.Intent.createChooser;
@@ -356,7 +357,9 @@ private void viewWithFileProvider(Mission mission) {
356357
viewIntent.addFlags(FLAG_GRANT_PREFIX_URI_PERMISSION);
357358

358359
Intent chooserIntent = createChooser(viewIntent, null);
359-
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION);
360+
chooserIntent.addFlags(FLAG_ACTIVITY_NEW_TASK);
361+
chooserIntent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
362+
chooserIntent.addFlags(FLAG_GRANT_PREFIX_URI_PERMISSION);
360363

361364
ShareUtils.openIntentInApp(mContext, chooserIntent);
362365
}
@@ -375,7 +378,7 @@ private void shareFile(Mission mission) {
375378
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) {
376379
intent.putExtra(Intent.EXTRA_TITLE, mContext.getString(R.string.share_dialog_title));
377380
}
378-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
381+
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
379382
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
380383

381384
mContext.startActivity(intent);

0 commit comments

Comments
 (0)