How to change 'open' in gallery intent to

2019-05-26 20:14发布

问题:

I am using following intent to open gallery for picking multiple images and videos:

        Intent intent = new Intent();
        intent.setType("image/* video/*");
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Images"), MULTIPLE_IMAGE_SELECT);

When the gallery is opened it looks like

In the top it says 'open' i want to change it to 'done' or 'ok', how to achieve that? Thanks.

回答1:

When the gallery is opened it looks like

There are ~2 billion Android devices, spread across thousands of device models. Your Intent will open one of hundreds, if not thousands, of possible Android apps installed on those devices. It does not have anything specific to do with a "gallery" and certainly has nothing to do with whatever specific app you have in your screenshot. That just happens to be what shows up when you run your code on one specific device.

how to achieve that?

You write your own UI, rather than delegating it to somebody else's app. You do not control the UI of other developers' apps.

As Ahmad points out, there are many image picker libraries. Perhaps you could use one.



回答2:

EDIT: Changed "images/*" to "image/*"

Change this line intent.setType("video/*, image/*");

    Intent intent = new Intent();
    intent.setType("video/*, image/*");
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Images"), MULTIPLE_IMAGE_SELECT);

Note: the EXTRA_ALLOW_MULTIPLE option is only available in Android API 18 and higher.

Can use custom lib. Like :

MultipleImagePick

MultiImageSelector

TelegramGallery