Sub SaveAs (Source As InputStream, MimeType As String, Title As String) As ResumableSub
Dim intent As Intent
intent.Initialize("android.intent.action.CREATE_DOCUMENT", "")
intent.AddCategory("android.intent.category.OPENABLE")
intent.PutExtra("android.intent.extra.TITLE", Title)
intent.SetType(MimeType)
StartActivityForResult(intent)
Wait For ion_Event (MethodName As String, Args() As Object)
If -1 = Args(0) Then 'resultCode = RESULT_OK
Dim result As Intent = Args(1)
Dim jo As JavaObject = result
Dim ctxt As JavaObject
Dim ContentResolver As JavaObject = ctxt.InitializeContext.RunMethodJO("getContentResolver", Null)
Dim out As OutputStream = ContentResolver.RunMethod("openOutputStream", Array(jo.RunMethod("getData", Null), "wt")) 'wt = Write+Trim
Log("Result:"&result.GetData)
Log("Out:"&out)
File.Copy2(Source, out)
out.Close
Return True
End If
Return False
End Sub