I have a button and I want the gallery to open when I click it, so far I have only loaded other activities in the following way:
Intent i = new Intent(this, MainSignUp.class );
startActivity(i);
But it is of classes that I have in my project.
The
Intent
ones you use so far areIntent
to open a specific activity. What you need to open the gallery is aIntent
to request an action class, in this caseACTION_VIEW
. Of course you will have to declare what type of element you want to display:The type refers to the mime type of the content, so if you want to open the default gallery for videos, use
"video/*"
instead of image.There are several ways, for example:
a)
b) You can also do this by accessing the images directory:
c) and this form using
Intent.createChooser()
: