Reputation: 5207
I am using the following code to open Gallery for image selection
private void galleryIntent() {
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_file)), SELECT_FILE);
All is working fine but for the first time it gives a popup with two options to select:
Can I make my app such that it always open Gallery Directly without any such popup?
Thanks
Upvotes: 0
Views: 2949
Reputation: 462
On Android 10 an intent with ACTION_PICK opens gallery
Intent().apply {
action = Intent.ACTION_PICK
type = "image/*"
}
when the intent with ACTION_GET_CONTENT opens file chooser
Intent().apply {
action = Intent.ACTION_GET_CONTENT
type = "image/*"
}
Upvotes: 0
Reputation: 13
try this:-
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"))
startActivity(intent);
or else u can try this...
Intent intent = new Intent();
intent.setType("image/*");
startActivity(intent);
Upvotes: 0
Reputation: 2845
Every gallery app has its own package name which can differ from device to device. To do what you intend, you must know the package name of the gallery app. Some device may not even have a default gallery app.
What you have done is the right way to go and the user can decide to set the gallery app as the default app. Unless for very important or specific reason, it is more reasonable to give the user the choice.
Look at Launching Gallery in android phones
Upvotes: 2
Reputation: 495
try this...
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE_REQUEST);
Upvotes: 0