Multiple MIME types in Android

后端 未结 6 2034
走了就别回头了
走了就别回头了 2020-12-01 00:42

Is there a way to use intent.setType() and supply multiple broad types (like images and video)?

I am using an ACTION_GET_CONTENT.

6条回答
  •  一整个雨季
    2020-12-01 01:16

    Sorry, this is not currently supported. You have two options:

    (1) Use a MIME type of */* and accept that there may be some things the user can pick that you won't be able to handle (and have a decent recovery path for that); or

    (2) Implement your own activity chooser, doing direct calls on the package manager to get the activities that can handle both MIME types for the intent, merging those lists, and displaying them to the user.

    Also, setType() does not work with comma-separated types at all. It must be one and only one MIME type.

提交回复
热议问题