Android的 - 启动库文件夹并选择图片 [英] Android - Launch Gallery Folder and Select Image

查看:168
本文介绍了Android的 - 启动库文件夹并选择图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做这需要使用画廊观看者的应用程序。我使用一个按钮来启动画廊活动。

I am doing an app which requires the use of the gallery viewer. I am using a button to launch the gallery activity.

通过使用这种code:

By using this code:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media"))); 

它返回我从不同的相册,在这里我只想要显示的默认相册画廊所有图像(这可能吗?),当我在图像上单击以查看它,它是罚款,直至我点击后退按钮,返回按钮就直接回我的应用程序,并且不留在画廊​​。我想后退按钮回到画廊(使用户可以查看过其他图像),这可能吗?

It returns me all the images in the gallery from different photo albums, where I would only want to display the default camera album (is this possible?), and when I click on the image to view it, it is fine until I click on the back button, the back button goes straight back to my app and does not stay in the gallery. I would like the back button to go back to the gallery (so that the user can view other images too), is that possible?

任何帮助将是AP preciated,感谢您的时间和贡献:)

Any help would be appreciated and thank you for your time and contribution :)

到目前为止,这是我已经得到了

So far, this is what I have gotten

Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setDataAndType(Uri.parse("content://media/external/images/media"), "image/*");
        startActivityForResult(intent, 0); 

但每当我加载点击加载图像,它引导我回我的应用程序没有直截了当加载图像。有人可以帮助我?谢谢!

But whenever I load click to load the image, it directs me back to my app straightaway without loading the image. Can someone help me with this? Thanks!

推荐答案

使用startActivityForResult()而不是startActivity()。伴随着这一点,你需要使用意图。 ACTION_PICK

Use startActivityForResult() instead of startActivity() since you need the data returned back to you. Along with this you need to use the Intent.ACTION_PICK.

具体来说,你需要有您的应用程序画廊这样做交互。这需要你返回图像返回给应用程序。

Specifically you need to have your application interact with the gallery to do this. Which would require you returning the image back to your application.

这是容易确定,如果你看一下清单的Gallery应用程序。

This is easy to determine if you look at the Manifest for the Gallery Application.

您可以在这里寻找它:
https://github.com/android

You can search for it here: https://github.com/android

更新库清单

<intent-filter>
           <action android:name="android.intent.action.PICK" />
           <category android:name="android.intent.category.DEFAULT" />
           <data android:mimeType="image/*" />
           <data android:mimeType="video/*" />
</intent-filter>

这意味着你只需要设置数据和MIME类型。

Meaning you just need to set the data and the mimetype.

这篇关于Android的 - 启动库文件夹并选择图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆