什么是iOS的“QL previewController或UIDocumentInteractionController在Android上的对应? [英] What is the counterpart of iOS' QLPreviewController or UIDocumentInteractionController on Android?
问题描述
在iOS上它是pretty的容易preVIEW许多类型的文件使用 QL previewController
或 UIDocumentInteractionController
。如何才能类似的东西可以实现在Android和什么文件格式的支持?
On iOS it's pretty easy to preview many types of files by using QLPreviewController
or UIDocumentInteractionController
. How can something similar be achieved on Android and what file formats are supported?
推荐答案
坏消息:没有内置(SDK级别)preVIEW组件/视图供您使用。
The bad news: there is no built-in (SDK level) preview component/View for you to use.
好消息:Android支持意图,使您可以利用其他应用程序做的工作为你所请求的文件类型返回一个选定的文件。
The good news: Android supports Intents that allow you to leverage other apps to do the work for you and return a selected file with a requested file type.
有几件事情可以做,取决于你的目标:
There are a few things that you can do depends on your targets:
-
API 19+:在设备与API 19,你应该使用的存储访问架构(<一href="https://developer.android.com/guide/topics/providers/document-provider.html">https://developer.android.com/guide/topics/providers/document-provider.html)所有previews等将在响应应用程序完成的。
API 19+: On device with API 19, you should use the Storage Access Framework (https://developer.android.com/guide/topics/providers/document-provider.html) All the previews etc will be done on the responding app.
您会考虑使用Intent.ACTION_OPEN_DOCUMENT。
You will be looking at using Intent.ACTION_OPEN_DOCUMENT.
有关旧设备:有,您可以使用可选的文件类型,您可以使用类别使用意图。这将打开任一个内置的文件选择或第三者应用
For older devices: There is an intent that you can use with optional file type and category you can use. This will open either a built-in file selector OR a third party app.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, REQUEST_CODE);
**注意,你可以在这里创建一个意向选择器。
**Note you could create a Intent chooser here.
对于不具有任何应用程序,可以响应意图设备:您可以捆绑一些prebuilt(<一href="https://$c$c.google.com/p/android-file-dialog/">https://$c$c.google.com/p/android-file-dialog/)或者根据文件类型,您可以查询的媒体文件的内容数据库,并显示它们自己一个很好的用户界面。
For devices that do not have any app that can respond to the Intent: You can either bundle something prebuilt (https://code.google.com/p/android-file-dialog/) or depending on the file type, you can query the content database for media files and display them yourself with a nice UI.
在如何使用意图和它是如何工作的附加参考:<一href="http://developer.android.com/guide/components/intents-filters.html">http://developer.android.com/guide/components/intents-filters.html
Additional Reference on how to use Intents and how it works: http://developer.android.com/guide/components/intents-filters.html
这篇关于什么是iOS的“QL previewController或UIDocumentInteractionController在Android上的对应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!