Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open gallery app from Android Intent

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); 

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.

Any help would be great.

Thanks

like image 938
Dfranc3373 Avatar asked Jun 04 '13 22:06

Dfranc3373


People also ask

How can I open gallery programmatically in Android?

To open gallery: (This should be in your activity class.) public OnClickListener btnChoosePhotoPressed = new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent. ACTION_PICK, android.

How do I access my gallery on Android?

On your Android phone, open Gallery . New folder. Enter the name of your new folder. Choose where you want your folder.

How do I launch my gallery?

From the Home screen, tap Apps > Gallery . Open Gallery from the Camera application by tapping the thumbnail image in the lower right corner of the screen.

How do I launch an activity using Intent?

To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.


1 Answers

This is what you need:

ACTION_VIEW 

Change your code to:

Intent intent = new Intent();   intent.setAction(android.content.Intent.ACTION_VIEW);   intent.setType("image/*"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 
like image 73
Umit Kaya Avatar answered Sep 28 '22 16:09

Umit Kaya