How do Android apps implement the share button?
I'm not a dev, so I just can give a raw explanation: apps declare in their Manifest which Mimetypes they understand and willing to respond to on share actions. For this they define so called "intent filters", e.g.:

&lt;intent-filter&gt;
    &lt;action android:name="android.intent.action.SEND" /&gt;
    &lt;category android:name="android.intent.category.DEFAULT"/&gt;
    &lt;data android:mimeType="application/*" /&gt;
    &lt;data android:mimeType="audio/*" /&gt;
    &lt;data android:mimeType="image/*" /&gt;
    &lt;data android:mimeType="message/*" /&gt;
    &lt;data android:mimeType="multipart/*" /&gt;
    &lt;data android:mimeType="text/*" /&gt;
    &lt;data android:mimeType="video/*" /&gt;
&lt;/intent-filter&gt;


So whenever you hit the "share" button, the content-to-share is evaluated and matched against apps having declared their willingness to receive the format.

Sources:


Intent Filter to capture all sharing Intents (StackOverflow)
Receiving Simple Data from Other Apps (developer.android.com)