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
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.
On your Android phone, open Gallery . New folder. Enter the name of your new folder. Choose where you want your folder.
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With