android - 使用已安装的文件编辑器(如果有)编辑纯文本文件的 Intent

标签 android android-intent plaintext

我希望我的应用程序使用我终端上安装的任何文件编辑器打开一个纯文本文件,但我一直收到此异常:

ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=file:///sdcard/folder/file.txt } 

首先我以为我没有安装文件编辑器,但如果我使用 ASTRO 文件管理器,我可以使用“文件编辑器”和“QuickOffice”打开文件,所以我认为问题在于我没有使用正确的代码...

这是代码

Intent intent = new Intent(Intent.ACTION_EDIT); 
Uri uri = Uri.parse("file:///sdcard/folder/file.txt"); 
intent.setDataAndType(uri, "plain/text"); 
startActivity(intent);

更令人惊讶的是,如果我使用不存在的文件的路径,它会不断引发相同的异常......

谢谢

最佳答案

MIME 类型是 text/plain

关于android - 使用已安装的文件编辑器(如果有)编辑纯文本文件的 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4539778/

相关文章:

android - ScrollView 下方的对象未显示

安卓/SQLite : Insert-Update table columns to keep the identifier

Android:设备重启时是否触发了 android.intent.action.DATE_CHANGED?

android - 如何从字符串数组资源中检索图像值并使用该值设置背景

java - Intent Android : click the button text is not transferred and show nothing

php - 在 PHP 代码中存储 SQL 登录信息的安全风险?

java - Android Fragment 可以覆盖 PhoneGap Activity 吗?

android - 如何在 flutter 中显示来自外部存储路径的图像?

r - 将 .Rd 文件转换为纯文本

javascript - 使用 AngularJs 将 html 内容作为纯文本粘贴到 contenteditable div 中