0

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.

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);
Emanuel Graf
  • 756
  • 17
  • 37
  • "this opens not the gallery app itself but in my app" -- what does "in my app" mean? This starts an activity. If that activity is from somebody else's app, then it would not be "open... in my app" by any typical use of the phrase "in my app". – CommonsWare Jun 28 '17 at 16:37
  • This means that not the gallery application is launched as an application itself, which could be seen in the current open apps for example.It is launched inside of the application which has called 'startActivity(intent)', in this example it's my own app. If you now watch the recent used apps, you would not be able to close the gallery app because the gallery is inside of the app which has called 'startActivity(intent)'. – Emanuel Graf Jun 28 '17 at 17:04

1 Answers1

1

It is launched inside of the application

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

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491