打开默认的照片库应用 [英] Open the default photo gallery app

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

问题描述

我希望图库应用程序在单独的窗口中启动,而不是在我的应用程序中启动.我也不想选择图片,我只想打开默认的图库应用程序. 一些问题与该问题非常相似,但它们都并非以独立应用程序,始终在已调用的应用程序内部 startActivity(intent);. 请参见此处.这是我的名为SM2的应用程序.在内部,默认的图库应用可见,这不是所需的行为.

I want the gallery app to be launched in a separate window, not in my app. I also dont want to choose a picture, I just want to open the default gallery app. Some questions are very similiar to this one, but they all open the gallery not as a standalone app, always inside of the app which has called startActivity(intent);. see here. This is my app called SM2. inside, the default gallery app is visible, which is not the desired behaviour.

如果电话上没有名为"com.android.gallery"的软件包,则以下代码无效:

The following code has no use if there is no package named 'com.android.gallery' on the phone:

           Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.gallery");
            if (launchIntent != null) {
                startActivity(launchIntent);//null pointer check in case package name was not found
            }

这会在我的应用程序中打开一个图库,而不像一个独立的任务那样:

this opens a gallery in my app, not as wished as a standalone task:

Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse(Environment.getExternalStoragePublicDirectory(
                            Environment.DIRECTORY_MOVIES)));
startActivity(intent1);

这也会在我的应用中打开图库:

and this does also open the gallery in my app:

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

推荐答案

它在应用程序内部启动

It is launched inside of the application

它正在您的任务中启动.您可以在Intent上使用FLAG_ACTIVITY_NEW_TASK使其启动.

It is being launched in your task. You can use FLAG_ACTIVITY_NEW_TASK on your Intent to have it launch in its own task.

我也不想选择图片,我只想打开默认的图库应用

I also dont want to choose a picture, I just want to open the default gallery app

欢迎您尝试使用CATEGORY_APP_GALLERY 尝试 ,尽管并非所有图库应用程序都可能具有支持此功能的活动.

You are welcome to try using CATEGORY_APP_GALLERY, though not all gallery apps might have an activity that supports this.

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

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