Java Code Examples for android.content.Intent#ACTION_OPEN_DOCUMENT_TREE
The following examples show how to use
android.content.Intent#ACTION_OPEN_DOCUMENT_TREE .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Notepad File: MainActivity.java License: Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void exportNotes() { filesToExport = cab.toArray(); cab.clear(); if(filesToExport.length == 1 || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { fileBeingExported = 0; reallyExportNotes(); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); try { startActivityForResult(intent, EXPORT_TREE); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } } }
Example 2
Source Project: Hentoid File: ImportHelper.java License: Apache License 2.0 | 6 votes |
private static Intent getFolderPickerIntent(@NonNull final Context context) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { intent.putExtra(DocumentsContract.EXTRA_PROMPT, "Allow Write Permission"); } // http://stackoverflow.com/a/31334967/1615876 intent.putExtra("android.content.extra.SHOW_ADVANCED", true); // Start the SAF at the specified location if (Build.VERSION.SDK_INT >= O && !Preferences.getStorageUri().isEmpty()) { DocumentFile file = DocumentFile.fromTreeUri(context, Uri.parse(Preferences.getStorageUri())); if (file != null) intent.putExtra(EXTRA_INITIAL_URI, file.getUri()); } HentoidApp.LifeCycleListener.disable(); // Prevents the app from displaying the PIN lock when returning from the SAF dialog return intent; }
Example 3
Source Project: Aegis File: PreferencesFragment.java License: GNU General Public License v3.0 | 6 votes |
private void selectBackupsLocation() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); startActivityForResult(intent, CODE_BACKUPS); }
Example 4
Source Project: syncthing-android File: FolderActivity.java License: Mozilla Public License 2.0 | 5 votes |
/** * Invoked after user clicked on the {@link mPathView} label. */ @SuppressLint("InlinedAPI") private void onPathViewClick() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { startActivityForResult(FolderPickerActivity.createIntent(this, mFolder.path, null), FolderPickerActivity.DIRECTORY_REQUEST_CODE); return; } // This has to be android.net.Uri as it implements a Parcelable. android.net.Uri externalFilesDirUri = FileUtils.getExternalFilesDirUri(FolderActivity.this); // Display storage access framework directory picker UI. Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); if (externalFilesDirUri != null) { intent.putExtra("android.provider.extra.INITIAL_URI", externalFilesDirUri); } intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); intent.putExtra("android.content.extra.SHOW_ADVANCED", true); try { startActivityForResult(intent, CHOOSE_FOLDER_REQUEST); } catch (android.content.ActivityNotFoundException e) { Log.e(TAG, "onPathViewClick exception, falling back to built-in FolderPickerActivity.", e); startActivityForResult(FolderPickerActivity.createIntent(this, mFolder.path, null), FolderPickerActivity.DIRECTORY_REQUEST_CODE); } }
Example 5
Source Project: FairEmail File: FragmentBase.java License: GNU General Public License v3.0 | 5 votes |
private void onStoreAttachments(Intent intent) { message = intent.getLongExtra("id", -1); Intent tree = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); Helper.openAdvanced(tree); PackageManager pm = getContext().getPackageManager(); if (tree.resolveActivity(pm) == null) // system whitelisted ToastEx.makeText(getContext(), R.string.title_no_saf, Toast.LENGTH_LONG).show(); else startActivityForResult(Helper.getChooser(getContext(), tree), REQUEST_ATTACHMENTS); }
Example 6
Source Project: Hentoid File: Api29MigrationActivity.java License: Apache License 2.0 | 5 votes |
private void selectHentoidFolder() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { intent.putExtra(DocumentsContract.EXTRA_PROMPT, "Allow Write Permission"); } // http://stackoverflow.com/a/31334967/1615876 intent.putExtra("android.content.extra.SHOW_ADVANCED", true); startActivityForResult(intent, RQST_STORAGE_PERMISSION); }
Example 7
Source Project: edslite File: ExternalStorageOpenerFragment.java License: GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void showSystemDialog() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, REQUEST_CODE_ADD_LOCATION); Toast.makeText(getActivity(), R.string.select_root_folder_tip, Toast.LENGTH_LONG).show(); }
Example 8
Source Project: andOTP File: SettingsActivity.java License: MIT License | 5 votes |
private void requestBackupAccess() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && settings.isBackupLocationSet()) intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, settings.getBackupLocation()); startActivityForResult(intent, Constants.INTENT_SETTINGS_BACKUP_LOCATION); }
Example 9
Source Project: microMathematics File: CompatUtils.java License: GNU General Public License v3.0 | 5 votes |
public static Intent getDocTreeIntent() { if (isMarshMallowOrLater()) { return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); } return null; }
Example 10
Source Project: memetastic File: ShareUtil.java License: GNU General Public License v3.0 | 5 votes |
/*** * Request storage access. The user needs to press "Select storage" at the correct storage. * @param activity The activity which will receive the result from startActivityForResult */ public void requestStorageAccessFramework(final Activity... activity) { Activity a = greedyGetActivity(activity); if (a != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION ); a.startActivityForResult(intent, REQUEST_SAF); } }
Example 11
Source Project: openlauncher File: ShareUtil.java License: Apache License 2.0 | 5 votes |
/*** * Request storage access. The user needs to press "Select storage" at the correct storage. * @param activity The activity which will receive the result from startActivityForResult */ public void requestStorageAccessFramework(final Activity... activity) { Activity a = greedyGetActivity(activity); if (a != null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION ); a.startActivityForResult(intent, REQUEST_SAF); } }
Example 12
Source Project: Nimingban File: SettingsActivity.java License: Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void openDirPickerL() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); try { startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), R.string.em_cant_find_activity, Toast.LENGTH_SHORT).show(); } }
Example 13
Source Project: tuxguitar File: TGSafBrowserUriRequest.java License: GNU Lesser General Public License v2.1 | 5 votes |
public void requestUriAccessIntentInCurrentThread() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.putExtra(EXTRA_SHOW_ADVANCED, true); TGSafBrowserUriResult handler = new TGSafBrowserUriResult(this); this.callStartActivityForResult(intent, handler.getRequestCode()); }
Example 14
Source Project: PowerFileExplorer File: MainActivityHelper.java License: GNU General Public License v3.0 | 4 votes |
private static void triggerStorageAccessFramework(final ThemedActivity mainActivity) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); mainActivity.startActivityForResult(intent, ThemedActivity.FROM_PREVIOUS_IO_ACTION); }
Example 15
Source Project: edslite File: DocumentTreeLocationsListFragment.java License: GNU General Public License v2.0 | 4 votes |
@Override protected void addNewLocation(String locationType) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, REQUEST_CODE_ADD_LOCATION); }
Example 16
Source Project: VinylMusicPlayer File: SAFUtil.java License: GNU General Public License v3.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void openTreePicker(Activity activity) { Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); i.putExtra("android.content.extra.SHOW_ADVANCED", true); activity.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE); }
Example 17
Source Project: VinylMusicPlayer File: SAFUtil.java License: GNU General Public License v3.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void openTreePicker(Fragment fragment) { Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); i.putExtra("android.content.extra.SHOW_ADVANCED", true); fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_TREE); }
Example 18
Source Project: Augendiagnose File: SettingsFragment.java License: GNU General Public License v2.0 | 4 votes |
/** * Trigger the storage access framework to access the base folder of the ext sd card. * * @param code The request code to be used. */ @RequiresApi(Build.VERSION_CODES.LOLLIPOP) private void triggerStorageAccessFramework(final int code) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, code); }
Example 19
Source Project: libcommon File: SAFUtils.java License: Apache License 2.0 | 2 votes |
/** * requestStorageAccessの下請け * @return */ private static Intent prepareStorageAccessPermission() { return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); }
Example 20
Source Project: libcommon File: SAFUtils.java License: Apache License 2.0 | 2 votes |
/** * requestStorageAccessの下請け * ドキュメントツリーへのアクセスのためのIntentを返す * @return */ private static Intent prepareStorageAccessPermission() { return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); }