简体   繁体   English

重用默认的Android图片库?

[英]Reusing default Android image gallery?

All the examples I've found online for displaying a gallery of images require creating a custom Adapter and doing a ton of manual work. 我在网上找到的用于显示图像库的所有示例都需要创建自定义适配器并进行大量手动工作。 Is there not an Intent that I can simply pass a path or filter to in order to reuse the default image gallery functionality (display thumbnails, touch to view full pic, sharing options, etc) but limit the results to my application's storage directory? 是否有一个Intent,我可以简单地传递一个路径或过滤器,以重用默认的图库功能(显示缩略图,触摸查看完整的图片,共享选项等),但限制结果到我的应用程序的存储目录?

  1. The Gallery application has no rights to access files in your application's storage directory. Gallery应用程序无权访问应用程序存储目录中的文件。

  2. The Gallery application is not part of the Android operating system. Gallery应用程序不是Android操作系统的一部分。

  3. The Gallery application is routinely replaced by device manufacturers with their own implementations, so even if you found some screwy back-door to the regular Gallery application that enabled this, it probably would not work on many devices. Gallery应用程序通常由具有自己实现的设备制造商取代,因此即使您发现了启用此功能的常规Gallery应用程序的一些棘手的后门,它也可能无法在许多设备上运行。

  4. Android itself, in the open source project, has two Gallery applications (Gallery and Gallery3D), and I don't know which are necessarily on any device (if either) or which is the one that you think supplies "the default image gallery functionality". Android本身,在开源项目中,有两个Gallery应用程序(Gallery和Gallery3D),我不知道哪些必须在任何设备上(如果有的话)或哪个是您认为提供的“默认图库功能”。

However, those Gallery applications are open source, and so you are welcome to copy whatever code you like out of them. 但是,这些Gallery应用程序是开源的,因此欢迎您复制任何您喜欢的代码。

You can use this code to get the gallery started. 您可以使用此代码来启动库。 Code for Video is 视频代码是

        Intent intent = new Intent();
        intent.setType("video/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Video"), 666);

code for Image is Image的代码是

        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Video"), 666);

And after getting the thing form the gallery , you can do whatever you want from it Do post if you need to ask anything else Thanks 从画廊中取出物品之后,你可以随心所欲地做任何事情。如果你需要问别的话,请发帖。谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM