我正在使用Intent打开文件管理器,我需要知道如何仅显示.doc和.docx文件供用户选择。 如何将setType放入Intent中?以下功能用于从文件管理器选择文件。
我正在使用Intent打开文件管理器,我需要知道如何仅显示.doc和.docx文件供用户选择。如何将setType设置给intent?以下函数用于从文件管理器选择文件。
private void showFileChooser() {
Intent intent = new Intent();
//sets the select file to all types of files
intent.setType("application/*");
//allows to select data and return it
intent.setAction(Intent.ACTION_GET_CONTENT);
//starts new activity to select file and return data
startActivityForResult(Intent.createChooser(intent, "Choose File to Upload.."), PICK_FILE_REQUEST);
}`