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?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The bad news: there is no built-in (SDK level) preview component/View for you to use.
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+: 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.
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.
**Note you could create a Intent chooser here.
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.
Additional Reference on how to use Intents and how it works: http://developer.android.com/guide/components/intents-filters.html