在Intent中设置Type来启动Activity



我试图同时打开文档和图像,我用SetType方法打开了Image和PDF,但是两者不能同时打开。有办法同时开门吗?这里我张贴了示例代码。

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.setType("application/pdf/*");

试试这个

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent .setType("*/*");
String[] mimeTypes = {"image/*", "application/pdf"};
intent .putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);

然后根据返回的结果定义类型

最新更新