當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.ACTION_CREATE_DOCUMENT屬性代碼示例

本文整理匯總了Java中android.content.Intent.ACTION_CREATE_DOCUMENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Intent.ACTION_CREATE_DOCUMENT屬性的具體用法?Java Intent.ACTION_CREATE_DOCUMENT怎麽用?Java Intent.ACTION_CREATE_DOCUMENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_CREATE_DOCUMENT屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performExport

private void performExport(final boolean includeGlobals, final Account account) {
    // TODO, prompt to allow a user to choose which accounts to export
    ArrayList<String> accountUuids = null;
    if (account != null) {
        accountUuids = new ArrayList<>();
        accountUuids.add(account.getUuid());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        exportGlobalSettings = includeGlobals;
        exportAccountUuids = accountUuids;

        Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.setType("application/octet-stream");
        intent.putExtra(Intent.EXTRA_TITLE, SettingsExporter.generateDatedExportFileName());
        intent.addCategory(Intent.CATEGORY_OPENABLE);

        startActivityForResult(intent, ACTIVITY_REQUEST_SAVE_SETTINGS_FILE);
    } else {
        startExport(includeGlobals, accountUuids, null);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:22,代碼來源:Accounts.java

示例2: exportDocument

/**
 * This method starts create document system activity.
 * @param activity
 * @param doc
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void exportDocument(Activity activity,
                                  DocumentMetadata doc) {
    Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);

    // show only results that can be "opened", such as a file
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // create a file with plain text MIME type
    intent.setType(MIME_TYPE);
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    String currentDate = sdf.format(new Date());
    String suggestedName = String.format(SUGGESTED_NAME_FORMAT, doc.getName(), currentDate);
    intent.putExtra(Intent.EXTRA_TITLE, suggestedName);
    activity.startActivityForResult(intent, WRITE_REQUEST_CODE);
}
 
開發者ID:nfdz,項目名稱:foco,代碼行數:21,代碼來源:ImportExportUtils.java

示例3: onBackupDone

public void onBackupDone(File file) {
    if (file == null) {
        setDone(R.string.error_generic);
        return;
    }
    if (Build.VERSION.SDK_INT >= 19) {
        mBackupFile = file;
        Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType(MimeTypeMap.getSingleton().getMimeTypeFromExtension("zip"));
        String date = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date());
        intent.putExtra(Intent.EXTRA_TITLE, "irc-client-backup-" + date + ".zip");
        startActivityForResult(intent, BACKUP_FILE_REQUEST_CODE);
        setSlideAnimation(false);
    } else {
        // TODO:
    }
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:18,代碼來源:BackupProgressActivity.java

示例4: saveTheFile

private void saveTheFile(boolean saveAs) {
    if (!saveAs && greatUri != null && greatUri.getUri() != null && greatUri.getUri() != Uri.EMPTY)
        new SaveFileTask(this, greatUri, pageSystem.getAllText(mEditor.getText()
                .toString()), currentEncoding, new SaveFileTask.SaveFileInterface() {
            @Override
            public void fileSaved(Boolean success) {
                savedAFile(greatUri, true);
            }
        }).execute();
    else {
        if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) {
            Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent.setType("*/*");
            intent.putExtra(Intent.EXTRA_TITLE, greatUri.getFileName());
            startActivityForResult(intent, SAVE_AS_REQUEST_CODE);
        } else {
            new NewFileDetailsDialog(
                    greatUri,
                    pageSystem.getAllText(mEditor.getText().toString()),
                    currentEncoding
            ).show(getFragmentManager().beginTransaction(), "dialog");
        }

    }
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:25,代碼來源:MainActivity.java

示例5: openFilePicker

@TargetApi(Build.VERSION_CODES.KITKAT)
public static void openFilePicker(Fragment fragment) {
    Intent i = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("audio/*");
    i.putExtra("android.content.extra.SHOW_ADVANCED", true);
    fragment.startActivityForResult(i, SAFUtil.REQUEST_SAF_PICK_FILE);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:8,代碼來源:SAFUtil.java

示例6: CreateFile

public void CreateFile(View view) {
    if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) {
        Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.setType("*/*");
        //intent.putExtra(Intent.EXTRA_TITLE, ".txt");
        startActivityForResult(intent, CREATE_REQUEST_CODE);
    } else {
        newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), "");
    }
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:10,代碼來源:MainActivity.java


注:本文中的android.content.Intent.ACTION_CREATE_DOCUMENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。