Android Question Making the app show up in the share menu

Martin Larsen

Active Member
Licensed User
Longtime User
This is probably a very simple question, but how do I make my app a target for the share menu?

My app can process certain webpages so the user should be able to open the share menu from his browser (Chrome, Firefox or whatever), pick my app on the list and then the app should receive the url to do its job.

Ideally, it should only show up for certain url patterns, like http://example.com/* but I am not sure if this is possible. It's not that important anyway.

I have seen examples using intent filters, but these examples open an app when the user clicks on certain links. This is not what I want. I only want my app to appear in the share menu.
 

Martin Larsen

Active Member
Licensed User
Longtime User
It works!

I am using this intent filter:

B4X:
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

I would have assumed that the correct mime type was text/html but that doesn't work. text/plain works but would probably make my app respond to some irrevalent mime types. However, that is not a big issue.

To get the url I do the following:

B4X:
Sub Activity_Resume
    Dim In As Intent, url As String
    In = Activity.GetStartingIntent
    If In.Action = "android.intent.action.SEND" Then
        Log(In)
        Log(In.ExtrasToString())
        If In.HasExtra("android.intent.extra.TEXT") Then
            url = In.GetExtra("android.intent.extra.TEXT")
            Log(url)
            WebViewExtras1.LoadUrl(url)
        End If
    End If
End Sub
 
Upvote 0
Top