按钮开始在Android图库 [英] Button to start the Gallery on Android
问题描述
我试图让我的应用程序打开内置的画廊按钮。
公共无效的onClick(视图v){
意图intentBrowseFiles =新意图(Intent.ACTION_VIEW);
intentBrowseFiles.setType(图像/ *);
intentBrowseFiles.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentBrowseFiles);
}
这将导致一个错误消息应用程序相机(进程com.android.gallery)意外停止。
如果我设置了意向行动ACTION_GET_CONTENT它设法打开图片库,但随后当选择一个图片是不是我想要的图像简单地返回到我的应用程序。
我试图让我的应用程序打开一个按钮,内置的浏览器。
块引用>画廊你的问题主题说。在问题的第一句话说:浏览器。这些都是不一样的东西。
如果我设置了意向行动ACTION_GET_CONTENT它设法打开图片库,但在选择一个图片是不是我想要的那么简单的返回形象我的应用程序。
块引用>当然,实际上是告诉我们是什么[你]想也只是太有用了,所以你让我们猜。
我要出去肢体和猜测,你试图打开图库应用程序只是作为一个正常的应用程序。需要注意的是在Android操作系统没有Gallery应用程序。有可能或不可能是任何给定的设备上的库应用,并且它可以是或可以不是一个来自Android的开源项目。
不过,对于已经在Android Market上他们的设备,他们应该支持
ACTION_VIEW
意图
用MIME键入从android.provider.MediaStore.Images.Media.CONTENT_TYPE
获得的。I'm trying to make a button in my App open the built in gallery.
public void onClick(View v) { Intent intentBrowseFiles = new Intent(Intent.ACTION_VIEW); intentBrowseFiles.setType("image/*"); intentBrowseFiles.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentBrowseFiles); }
This results in an error message "The application Camera (process com.android.gallery) has stopped unexpectedly."
If I set the Intent action to ACTION_GET_CONTENT it manages to open the gallery but then simply returns the image to my app when a picture is selected which is not what I want.
解决方案I'm trying to make a button in my App open the built in browser.
Your question subject says "Gallery". Your first sentence in the question says "browser". These are not the same thing.
If I set the Intent action to ACTION_GET_CONTENT it manages to open the gallery but then simply returns the image to my app when a picture is selected which is not what I want.
Of course, actually telling us "what [you] want" would just be too useful, so you are making us guess.
I am going to go out on a limb and guess that you are trying to open the Gallery application just as a normal application. Note that there is no Gallery application in the Android OS. There may or may not be a Gallery application on any given device, and it may or may not be one from the Android open source project.
However, for devices that have the Android Market on them, they should support an
ACTION_VIEW
Intent
with a MIME type obtained fromandroid.provider.MediaStore.Images.Media.CONTENT_TYPE
.这篇关于按钮开始在Android图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!