Android开放图库应用

时间:2013-10-17 20:14:30

标签: android button gallery

我有一个按钮可以打开android gallery app。我使用代码

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

for Android> = 2.3在此处找到:Open Gallery App in Android

我的问题:当用户从我的应用程序打开图库并离开图库(主页按钮,共享图像,..)时,图库将在下次用户打开我的应用程序时显示(无需单击按钮)。

打开我的应用时,如何避免我的应用中显示图库?只有在单击按钮时才会显示一次图库,但下次我的应用程序不在前面时才会显示。

1 个答案:

答案 0 :(得分:4)

根据您的要求,您最好的选择是告诉Android不要在您的任务历史记录中保存图库。这样,当他们离开Gallery活动时,它将不会出现在任务的历史堆栈中。通过在你的意图上设置一个标志来做到这一点。

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media")); 
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);