本文整理汇总了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);
}
}
示例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);
}
示例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:
}
}
示例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");
}
}
}
示例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);
}
示例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, "", ""), "");
}
}