For the Intent Chooser, is it possible to set which sharing items to show, and in which order?

前端 未结 1 1974
灰色年华
灰色年华 2020-12-19 03:28

Background

Before Android Q, it was always possible to set which items to show on the sharing dialog, and in which order. I even wrote about it here.

For e

相关标签:
1条回答
  • 2020-12-19 03:53

    Let me see if I can answer some of your questions.

    On the native share UI, Is there any way to set which items to show, each with its own Intent, and in which order?

    You can use what you're using now, but, as you discovered, it's only possible to provide 2 intents to specifically promote to the top. That said, the change to get the system to populate the rest of the list in alpha order is small:

        val chooserIntent = Intent.createChooser(
            when {
                Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> intent
                Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> Intent()
                else -> targetIntents.removeAt(0)
            }, chooserTitle
        )
    

    This actually looks like what you were doing according to the bug report.

    Unfortunately, it's not possible to change the title from "Share" when using Intent.ACTION_SEND or Intent.ACTION_SEND_MULTIPLE.

    Seeing that there is EXTRA_CHOOSER_TARGETS, does it mean I can get the direct-share items myself?

    No. It's provided so that your app can surface its own direct share targets that are appropriate for the action being taken. (source)

    0 讨论(0)
提交回复
热议问题