Sub Activity_Resume
Log(Activity.GetStartingIntent.ExtrasToString)
If Activity.GetStartingIntent.Action="android.intent.action.MAIN" Then
'app was started by the user (not by "sharing to") so there's no file(s) to get...
Return
End If
'App was started via "share to..." with textfile(s)
FileList=GetUrisFromStartingIntent(Activity.GetStartingIntent)
If FileList.Size>0 Then
For i=0 To FileList.Size-1
Dim uri As String = FileList.Get(i)
Try
File.Copy("ContentDir",uri,File.DirInternal & "/somefolderifneeded" ,"FileName".txt") 'change to unique filename otherwise it's overwritten...
Catch
Log(LastException)
End Try
Next
End If
End Sub
Private Sub GetUrisFromStartingIntent(in As Intent) As List
Log(in.Action)
Log(in.ExtrasToString)
Dim FileList As List
FileList.Initialize
If in.IsInitialized And in <> OldIntent Then
If in.Action = "android.intent.action.SEND" Or in.Action= "android.intent.action.SEND_MULTIPLE" Then
FileList= GetImageUrisFromExtras(in.ExtrasToString, in.action)
End If
OldIntent = in
End If
Return FileList
End Sub
Sub GetImageUrisFromExtras (Extras As String, Intent As String) As List
Log(Extras)
Dim FileList As List
FileList.Initialize
Dim JO As JavaObject = Activity.GetStartingIntent
Select Intent
Case "android.intent.action.SEND"
Dim uri As String = JO.RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
FileList.Add(uri)
Case "android.intent.action.SEND_MULTIPLE"
Dim uris As List = JO.RunMethod("getParcelableArrayListExtra", Array("android.intent.extra.STREAM"))
If uris.Size > 0 Then
For i = 0 To uris.Size-1
FileList.Add(uris.Get(i))
Next
End If
End Select
Return FileList
End Sub