本文整理匯總了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, "", ""), "");
}
}