Java Code Examples for android.content.Intent.ACTION_OPEN_DOCUMENT_TREE

The following are Jave code examples for showing how to use ACTION_OPEN_DOCUMENT_TREE of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: microMathematics   File: CompatUtils.java   View Source Code Vote up 7 votes
public static Intent getDocTreeIntent()
{
    if (isMarshMallowOrLater())
    {
        return new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    }
    return null;
}
 
Example 2
Project: orgzly-android   File: DirectoryRepoFragment.java   View Source Code Vote up 6 votes
private void onOpenBrowser() {
    boolean browserStarted = false;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {

        /*
         * Apparently some devices do not handle this intent.
         * Fallback to internal browser.
         */
        try {
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            getActivity().startActivityForResult(intent, ReposActivity.ACTION_OPEN_DOCUMENT_TREE_REQUEST_CODE);
            browserStarted = true;

        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
        }
    }

    if (! browserStarted) {
        Activity activity = getActivity();

        if (activity != null) {
            /* Close the keyboard before opening the browser. */
            ActivityUtils.closeSoftKeyboard(getActivity());

            /* Open internal browser. */
            ((CommonActivity) activity).runWithPermission(
                    AppPermissions.Usage.LOCAL_REPO,
                    this::startBrowserDelayed
            );
        }
    }
}
 
Example 3
Project: music_player   File: menu_util.java   View Source Code Vote up 5 votes
public static void openSAF(Activity context) {

        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        context.startActivityForResult(intent, 42);
    }
 
Example 4
Project: RetroMusicPlayer   File: SAFUtil.java   View Source Code Vote up 5 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 5
Project: RetroMusicPlayer   File: SAFUtil.java   View Source Code Vote up 5 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);
}