Example usage for android.content Intent ACTION_OPEN_DOCUMENT_TREE

List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT_TREE

Introduction

In this page you can find the example usage for android.content Intent ACTION_OPEN_DOCUMENT_TREE.

Prototype

String ACTION_OPEN_DOCUMENT_TREE

To view the source code for android.content Intent ACTION_OPEN_DOCUMENT_TREE.

Click Source Link

Document

Activity Action: Allow the user to pick a directory subtree.

Usage

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

@SuppressLint("InlinedApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_STORAGE_ACCESS) {
        if (resultCode == Activity.RESULT_OK) {
            if (SafUtil.isSafExternalSdcardRootTreeUri(mSafCA, data.getData())) {
                SafUtil.saveSafExternalSdcardRootTreeUri(mSafCA, data.getData().toString());
            } else {
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
                startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCESS);
            }// ww  w  .j  av a2 s. c  om
        }
    } else if (requestCode == 0) {
        if (resultCode == Activity.RESULT_OK)
            applySettingParms();
    }
}

From source file:com.free.searcher.MainFragment.java

/**
 * Trigger the storage access framework to access the base folder of the ext sd card.
 *
 * @param code The request code to be used.
 */// w w  w. j a v  a  2  s  . com
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void triggerStorageAccessFramework(final int code) {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
    startActivityForResult(intent, code);
}

From source file:com.sentaroh.android.SMBSync2.ActivityMain.java

@SuppressLint("InlinedApi")
private void checkSafExternalSdcardTreeUri(final NotifyEvent p_ntfy) {
    if (profUtil.isExternalSdcardUsedByOutput()) {
        if (SafUtil.hasSafExternalSdcard(mSafCA) && !SafUtil.isValidSafExternalSdcardRootTreeUri(mSafCA)) {
            NotifyEvent ntfy = new NotifyEvent(mContext);
            ntfy.setListener(new NotifyEventListener() {
                @Override// w ww  .  ja v a 2  s .  c om
                public void positiveResponse(Context c, Object[] o) {
                    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
                    startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCESS);
                    //                   if (p_ntfy!=null) p_ntfy.notifyToListener(true, null);
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    if (p_ntfy != null)
                        p_ntfy.notifyToListener(false, null);
                }
            });
            profUtil.showSelectSdcardMsg(ntfy,
                    mContext.getString(R.string.msgs_main_external_sdcard_select_required_select_msg));
        } else {
            if (p_ntfy != null)
                p_ntfy.notifyToListener(true, null);
        }
    } else {
        if (p_ntfy != null)
            p_ntfy.notifyToListener(true, null);
    }
}

From source file:com.sentaroh.android.SMBSync2.ActivityMain.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0) {
        util.addDebugMsg(1, "I", "Return from Settings.");
        reloadSettingParms();//from   w ww .j  a  v a  2s .co  m
        if (mGp.syncTaskAdapter.isShowCheckBox())
            setProfileContextButtonSelectMode();
        else
            setProfileContextButtonNormalMode();
    } else if (requestCode == 1) {
        util.addDebugMsg(1, "I", "Return from browse log file.");
    } else if (requestCode == REQUEST_CODE_STORAGE_ACCESS) {
        util.addDebugMsg(1, "I", "Return from Storage Picker.");
        if (resultCode == Activity.RESULT_OK) {
            util.addDebugMsg(1, "I", "Intent=" + data.getData().toString());
            if (SafUtil.isSafExternalSdcardRootTreeUri(mSafCA, data.getData())) {
                //                 String prev_uri_string=SafUtil.getSafExternalSdcardRootTreeUri(mSafCA);
                SafUtil.saveSafExternalSdcardRootTreeUri(mSafCA, data.getData().toString());
                if (mSafSelectActivityNotify != null)
                    mSafSelectActivityNotify.notifyToListener(true, null);
            } else {
                NotifyEvent ntfy = new NotifyEvent(mContext);
                ntfy.setListener(new NotifyEventListener() {
                    @Override
                    public void positiveResponse(Context c, Object[] o) {
                        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
                        startActivityForResult(intent, REQUEST_CODE_STORAGE_ACCESS);
                    }

                    @Override
                    public void negativeResponse(Context c, Object[] o) {
                    }
                });
                profUtil.showSelectSdcardMsg(ntfy,
                        mContext.getString(R.string.msgs_main_external_sdcard_select_required_select_msg));
            }
        } else {
            SyncTaskItem pli = SyncTaskUtility.getExternalSdcardUsedSyncProfile(mGp);
            String msg = String.format(
                    mContext.getString(R.string.msgs_main_external_sdcard_select_required_cancel_msg),
                    pli.getSyncTaskName());
            commonDlg.showCommonDialog(false, "W",
                    mContext.getString(R.string.msgs_main_external_sdcard_select_required_title), msg, null);
        }

    }
}