When I needed this I had to search for a while to get the pieces together, so I thought it would be helpful for others:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddApplicationText(
<activity android:name="main" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
)
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example Browserklink
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Public pgiLastIntent As Intent
End Sub
Sub Globals
Private Label1 As Label
Private Label2 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
Label1.Text = $"Open a website in a browser and select 'Share'${CRLF}It even works with youtube links"$
End Sub
Sub Activity_Resume
Dim intActIntent As Intent
intActIntent.Initialize("","")
intActIntent = Activity.GetStartingIntent
If intActIntent <> Null Then
If intActIntent <> pgiLastIntent Then
pgiLastIntent = intActIntent
Dim sb As StringBuilder : sb.Initialize
sb.Append("ExtrasToString = ").Append(intActIntent.ExtrasToString).Append(CRLF).Append(CRLF).Append(CRLF)
sb.Append("GetData = ").Append(intActIntent.GetData).Append(CRLF).Append(CRLF).Append(CRLF)
If intActIntent.HasExtra("android.intent.extra.TEXT") Then
sb.Append("extra.TEXT = ").Append(intActIntent.GetExtra("android.intent.extra.TEXT")).Append(CRLF).Append(CRLF).Append(CRLF)
End If
If intActIntent.HasExtra("android.intent.extra.SUBJECT") Then
sb.Append("extra.SUBJECT = ").Append(intActIntent.GetExtra("android.intent.extra.SUBJECT")).Append(CRLF).Append(CRLF).Append(CRLF)
End If
Label2.Text = sb.ToString
End If
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub