This example shows how to create an app that can act as a sharing target. It will be listed in the list of apps that show when the user shares an image.
The first step is to add an intent filter to the manifest editor. The intent filter tells the OS which types of resources the app supports:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
The second step is to check the starting intent in Activity_Resume and see whether it is a sharing intent. If so then we extract the uri from the intent and load the bitmap. The uri scheme is expected to be content://.
As we don't want to handle the same intent twice we need to compare it to the previous intent and make sure that it is not identical:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Tip: Test it in release mode. Otherwise the process might be killed while the app is in the background and it will fail to start when the image is shared.
			
			The first step is to add an intent filter to the manifest editor. The intent filter tells the OS which types of resources the app supports:
			
				B4X:
			
		
		
		AddActivityText(Main,
<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="image/*" />
</intent-filter>)
	The second step is to check the starting intent in Activity_Resume and see whether it is a sharing intent. If so then we extract the uri from the intent and load the bitmap. The uri scheme is expected to be content://.
As we don't want to handle the same intent twice we need to compare it to the previous intent and make sure that it is not identical:
			
				B4X:
			
		
		
		#BridgeLogger: True
Sub Process_Globals
   Private OldIntent As Intent
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
End Sub
Sub Activity_Resume
   If IsRelevantIntent(Activity.GetStartingIntent) Then
     Dim in As JavaObject = Activity.GetStartingIntent
     Dim uri As String = in.RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
     Try
       Log("Loading bitmap from: " & uri)
       Dim bmp As Bitmap = LoadBitmapSample("ContentDir", uri, 100%x, 100%y)
       Activity.SetBackgroundImage(bmp)
     Catch
       Log(LastException)
     End Try
   End If
End Sub
Private Sub IsRelevantIntent(in As Intent) As Boolean
   If in.IsInitialized And in <> OldIntent And in.Action = in.ACTION_SEND Then
     OldIntent = in
     Return True
   End If
   Return False
End Sub
	Tip: Test it in release mode. Otherwise the process might be killed while the app is in the background and it will fail to start when the image is shared.