是否可以将存储访问框架与ACTION_CREATE_DOCUMENT一起使用并使文件名变为粘滞 - 用户无法更改?
此文档中的代码创建了一个新窗口,以便用户可以选择新文件的位置,还可以更改文件名。后者是不受欢迎的......
private void createFile(String mimeType, String fileName) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
// Filter to only show results that can be "opened", such as
// a file (as opposed to a list of contacts or timezones).
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Create a file with the requested MIME type.
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_TITLE, fileName);
startActivityForResult(intent, WRITE_REQUEST_CODE);
}
我已经找到了答案,但一直找不到。是保存文件后重命名文件的唯一方法吗?
答案 0 :(得分:0)
没有。看一下com.android.documentsui.SaveFragement的来源。有一个textwatcher没有强制执行我们有权访问的任何内容,并且从com.android.documentsui.DocumentActivity.java调用的方法setSaveEnabled()仅基于强制执行写目录的权限,但没有强制执行文件命名约定。