如何使用 Intent 通过 DataViz 的 Documents To Go 打开 ppt
我有一个 Android 应用程序,除其他外,它还可以下载文档。我想提供使用其他应用程序(例如 DataViz 的 Documents To Go 查看器应用程序)打开这些文档的功能。我已经查看了相当多的代码并搜索了这里的其他问题,我认为我只是没有做正确的事情。
例如,假设我正在下载一个 ppt。这段代码应该在下载文档之前验证应用程序是否支持文档类型。
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/ppt");
PackageManager packageManager = getPackageManager();
List intentList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (intentList.size() == 0) {
// error
}
由于某种原因,这段代码没有在我的设备上注册 DataViz 的应用程序或其他文档查看器。
当然,如果我要调用 startActivity(intent);那会抛出异常。
I have an Android app that among other things is able to download documents. I would like to offer the ability to open these documents with other apps like DataViz's Documents To Go viewer apps. I've looked at quite a bit of code and searched through the other questions on here and I think I'm just not doing something quite right.
For example, let's pretend I'm downloading a ppt. This bit of code is supposed to verify that the document type is supported by an app before downloading the document.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/ppt");
PackageManager packageManager = getPackageManager();
List intentList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (intentList.size() == 0) {
// error
}
For some reason this bit of code doesn't register DataViz's apps or the other document viewer on my device.
And of course, if I were to call startActivity(intent); that would throw an exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
application/vnd.ms-powerpoint
作为 mime 类型。Try using
application/vnd.ms-powerpoint
as the mime type.