【发布时间】:2011-11-14 16:42:29
【问题描述】:
我尝试在 Android 上创建一个小文件资源管理器,并且我希望系统在现有应用程序时打开文件,就像默认文件资源管理器一样。
例如,如果您单击 MP3 文件,我想打开媒体播放器,以及用于 PDF 的 pdf 阅读器等等。
我无法在 Internet 上找到任何来源。我目前正在使用这个:
try {
Intent myIntent = new Intent(
android.content.Intent.ACTION_VIEW, Uri
.parse("file://"
+ myFile.getAbsolutePath()));
startActivity(myIntent);
} catch (Exception e) {
Log.e(TAG, "Not possible to resolve this intent.");
Toast.makeText(getApplicationContext(),
"This file cannot be opened from here.",
Toast.LENGTH_SHORT).show();
}
但它仅适用于 PDF...关于如何在不“手动”设置正确的 MIME 类型的情况下获得与文件资源管理器相同的行为的任何想法?
这里是整个项目的代码源:https://github.com/rbochet/Rhizome-Retriever
【问题讨论】:
标签: android file android-intent mime-types