【发布时间】:2016-07-07 07:46:52
【问题描述】:
我想使用意图选择器打开我的应用程序中的任何文件 - 不幸的是,来自选择器的提议......很奇怪。选择png 文件后,它只显示一个选项 - Drive PDF Viewer。但是当我尝试使用默认文件资源管理器打开同一个文件时,它正确地建议使用画廊或照片。
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.toLowerCase());
Log.i(TAG, mime); // <------------ image/png
Intent intent= new Intent(Intent.ACTION_VIEW);
intent.setType(mime);
intent.setData(Uri.fromFile(file)); // <----- png file
Intent chooser = Intent.createChooser(intent, "Choose an application to open with:");
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(chooser);
这里有什么问题?
【问题讨论】:
-
如果改成:intent.setType("image/*");有用吗?
标签: android android-intent gallery filechooser