android.content.Intent#ACTION_OPEN_DOCUMENT_TREE源码实例Demo

下面列出了android.content.Intent#ACTION_OPEN_DOCUMENT_TREE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Notepad   文件: MainActivity.java
@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);
        }
    }
}
 
源代码2 项目: Hentoid   文件: ImportHelper.java
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;
}
 
源代码3 项目: syncthing-android   文件: FolderActivity.java
/**
 * 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);
    }
}
 
源代码4 项目: FairEmail   文件: FragmentBase.java
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);
}
 
源代码5 项目: Hentoid   文件: Api29MigrationActivity.java
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);
}
 
源代码6 项目: edslite   文件: ExternalStorageOpenerFragment.java
@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();
}
 
源代码7 项目: andOTP   文件: SettingsActivity.java
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);
}
 
源代码8 项目: microMathematics   文件: CompatUtils.java
public static Intent getDocTreeIntent()
{
    if (isMarshMallowOrLater())
    {
        return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    }
    return null;
}
 
源代码9 项目: memetastic   文件: ShareUtil.java
/***
 * 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);
    }
}
 
源代码10 项目: Aegis   文件: PreferencesFragment.java
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);
}
 
源代码11 项目: openlauncher   文件: ShareUtil.java
/***
 * 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);
    }
}
 
源代码12 项目: Nimingban   文件: SettingsActivity.java
@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();
    }
}
 
源代码13 项目: tuxguitar   文件: TGSafBrowserUriRequest.java
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());
}
 
源代码14 项目: PowerFileExplorer   文件: MainActivityHelper.java
private static void triggerStorageAccessFramework(final ThemedActivity mainActivity) {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    mainActivity.startActivityForResult(intent, ThemedActivity.FROM_PREVIOUS_IO_ACTION);
}
 
@Override
protected void addNewLocation(String locationType)
{
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    startActivityForResult(intent, REQUEST_CODE_ADD_LOCATION);
}
 
源代码16 项目: VinylMusicPlayer   文件: SAFUtil.java
@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);
}
 
源代码17 项目: VinylMusicPlayer   文件: SAFUtil.java
@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);
}
 
源代码18 项目: Augendiagnose   文件: SettingsFragment.java
/**
 * 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);
}
 
源代码19 项目: libcommon   文件: SAFUtils.java
/**
 * requestStorageAccessの下請け
 * @return
 */
private static Intent prepareStorageAccessPermission() {
	return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
}
 
源代码20 项目: libcommon   文件: SAFUtils.java
/**
 * requestStorageAccessの下請け
 * ドキュメントツリーへのアクセスのためのIntentを返す
 * @return
 */
private static Intent prepareStorageAccessPermission() {
	return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
}
 
 方法所在类
 同类方法