|
5 | 5 | import android.content.Intent;
|
6 | 6 | import android.database.Cursor;
|
7 | 7 | import android.net.Uri;
|
| 8 | +import android.os.Build; |
8 | 9 | import android.provider.DocumentsContract;
|
9 | 10 | import android.provider.MediaStore;
|
10 | 11 |
|
|
17 | 18 |
|
18 | 19 | import static androidx.core.app.ActivityCompat.startActivityForResult;
|
19 | 20 |
|
| 21 | +import static com.hippo.ehviewer.client.EhConfig.TORRENT_PATH; |
| 22 | + |
20 | 23 | import com.hippo.unifile.UniFile;
|
21 | 24 | import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
22 | 25 |
|
@@ -84,19 +87,23 @@ public static void openAssignFolder(String path, Context context) {
|
84 | 87 | if (!file.exists()) {
|
85 | 88 | return;
|
86 | 89 | }
|
| 90 | + Intent intent; |
87 | 91 |
|
88 |
| - Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload"); |
89 | 92 | // Uri uri = Uri.parse(path);
|
90 |
| - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); |
91 |
| - intent.addCategory(Intent.CATEGORY_OPENABLE); |
92 |
| - intent.setType("*/*"); |
93 |
| - intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri); |
94 |
| - |
95 |
| -// |
96 |
| -// Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
97 |
| -// intent.addCategory(Intent.CATEGORY_DEFAULT); |
98 |
| -// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
99 |
| -// intent.setDataAndType(Uri.fromFile(file), "file/*"); |
| 93 | + |
| 94 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 95 | + Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload/"+TORRENT_PATH); |
| 96 | + intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); |
| 97 | + intent.addCategory(Intent.CATEGORY_OPENABLE); |
| 98 | + intent.setType("*/*"); |
| 99 | + intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri); |
| 100 | + }else{ |
| 101 | + intent = new Intent(Intent.ACTION_GET_CONTENT); |
| 102 | + intent.addCategory(Intent.CATEGORY_OPENABLE); |
| 103 | + intent.setType("*/*"); |
| 104 | + intent.setDataAndType(Uri.fromFile(file), "file/*"); |
| 105 | + } |
| 106 | + |
100 | 107 |
|
101 | 108 | try {
|
102 | 109 | // context.startActivity(intent);
|
|
0 commit comments