从 Android Intent 打开图库应用 [英] Open gallery app from Android Intent

查看:31
本文介绍了从 Android Intent 打开图库应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从 Intent 中打开 Android 画廊应用程序的方法.

I'm looking for a way to open the Android gallery application from an intent.

我不想返回图片,而只是打开图库以允许用户使用它,就像他们从启动器中选择它一样(查看图片/文件夹).

I do not want to return a picture, but rather just open the gallery to allow the user to use it as if they selected it from the launcher (View pictures/folders).

我已尝试执行以下操作:

I have tried to do the following:

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);  
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

然而,这会导致应用程序在我选择图片后关闭(我知道这是因为 ACTION_GET_CONTENT),但我只需要打开图库.

However this is causing the application to close once I select a picture (I know this is because of the ACTION_GET_CONTENT), but I need to just open the gallery.

任何帮助都会很棒.

谢谢

推荐答案

这就是你所需要的:

ACTION_VIEW

将您的代码更改为:

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_VIEW);  
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

这篇关于从 Android Intent 打开图库应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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