使用intent在android中打开文件
使用意图使我的应用程序从电子邮件应用程序启动后,如何打开导致启动的文件?通常我只是使用
fis = openFileInput("test.txt");
但由于它只是从意图启动应用程序我不知道名称。我假设这与获取 URI 有关。我正在使用启动应用程序
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.xls" />
</intent-filter>
After using a intent to cause my app to launch from the email application, how do I open the file that caused the launch? Normally I just use
fis = openFileInput("test.txt");
But since its just launching the application from a intent I don't know the name. I am assuming it will have something to do with acquiring the URI. I am launching the app using
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.xls" />
</intent-filter>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取文件的 InputStream,您可以在 Activity 的
onCreate()
方法中使用如下代码:To get InputStream for the file you could use the code like this in your Activity's
onCreate()
method: