好的,我用这个开始我的功能
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(mimeType);
intent.addCategory(Intent.CATEGORY_OPENABLE);
Run Code Online (Sandbox Code Playgroud)
三星
chooserIntent = Intent.createChooser(sIntent, context.getString(R.string.choosefilefrom));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {intent});
Run Code Online (Sandbox Code Playgroud)
对于其他设备
chooserIntent = Intent.createChooser(intent, context.getString(R.string.choosefilefrom));
Run Code Online (Sandbox Code Playgroud)
mimeType 是允许使用的类型,此时为*/*. 但是如何排除图像和视频以仅显示文件选择器中的文件?我有 3 种意图,一种用于图像,一种用于视频,一种用于文件。