Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓开放画廊应用程序_Android_Button_Gallery - Fatal编程技术网

Android 安卓开放画廊应用程序

Android 安卓开放画廊应用程序,android,button,gallery,Android,Button,Gallery,我有一个打开android gallery应用程序的按钮。我使用代码 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse( "content://media/internal/images/media")); startActivity(intent); 对于Android>=2.3,可在此处找到: 我的问题:当用户从我的应用程序打开图库并离开图库(主页按钮、共享图像等)时,该图库将在下次用户打开我的应用程序时显示(无需单击

我有一个打开android gallery应用程序的按钮。我使用代码

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
 "content://media/internal/images/media")); 
 startActivity(intent); 
对于Android>=2.3,可在此处找到:

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


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

根据您的要求,您最好的选择是告诉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);

考虑到您的需求,您最好的选择是告诉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);