How to change 'open' in gallery intent to 'done'?

谁都会走 提交于 2019-12-22 18:42:25

问题


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



来源:https://stackoverflow.com/questions/45628865/how-to-change-open-in-gallery-intent-to-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!