androidandroid-intentandroid-sharesheet

Adding destinations to the Android sharesheet


In Android, there is the system sharesheet. I can see that some apps (WhatsApp, Telegram) insert destinations for specific people into it. When an app opens the shareseet, I can see a couple of recently talked with WhatsApp contacts as destinations in the top row. When the sharesheet is coming up, there is a small delay while the top row is being populated - presuming the sharesheet is collecting destinations from WhatsApp and the like.

I know for a fact that the app has no foreknowledge about WhatsApp or Telegram - the app with the Share function that I'm observing it on is mine.

How does an app advertise itself as a provider of custom share destinations (like WhatsApp does)?


Solution

  • It appears as though you are referring to Direct Share targets. That is an Android 10-and-up feature, using ShorcutManagerCompat to provide options for Android to consider.

    As is noted in the Sharing Shortcuts FAQ, Android 6 through 9 had you implement a ChooserTargetService.