Android - ShareActionProvider Share Menu add particular option

删除回忆录丶 提交于 2021-01-29 18:55:15

问题


This is what I have:

val imgURL = "https://blaaaa.com/pic.jpg"

val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
shareIntent.type = "text/plain"

shareIntent.putExtra(
    Intent.EXTRA_TEXT,
    context.getString(R.string.check_this_out) + " " + domain + "/post/?id=" + meme.id
)

context.startActivity(
    Intent.createChooser(
        shareIntent,
        context.getString(R.string.send_to)
    )
)

This way I'm sending a text to any available app in the share menu.

But I need to add one PARTICULAR option that doesn't send the text but opens a new activity called DownloadImage and sends the string imgURL to it.

Like this:

This doc: https://developer.android.com/training/sharing/send#adding-custom-targets isn't helping because it only shows how to change the content type that is sent to all apps globally.

I've seen this in other apps so this is possible.

来源:https://stackoverflow.com/questions/64412704/android-shareactionprovider-share-menu-add-particular-option

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