意图用于编辑纯文本文件与已安装的文件编辑器(如果有的话) [英] Intent for editing plain text file with the installed file editor (if any)

查看:127
本文介绍了意图用于编辑纯文本文件与已安装的文件编辑器(如果有的话)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序可以与任何安装在我的终端上的文件编辑器打开一个纯文本文件,但我不断收到此异常:

I want my app to open a plain text file with any of the file editors installed on my terminal, but I keep getting this exception:

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

首先,我认为我没有安装文件编辑器,但如果我用ASTRO文件管理器,我可以用文件编辑器和Quickoffice的打开文件这两个,所以我认为这个问题是我未使用正确的code ...

First I thought that I have no File editor installed, but if I use ASTRO file manager, I can get to open the file both with "File Editor" and "QuickOffice", so I think the problem is that I'm not using the right code...

下面是code

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

什么是更令人惊讶的是,如果我使用的文件不存在的路径,它不断提高相同的异常...

What is more surprising is that if I use the path of a file that doesn't exist, it keeps raising the same exception...

感谢

推荐答案

MIME类型为文本/纯

这篇关于意图用于编辑纯文本文件与已安装的文件编辑器(如果有的话)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆