I'm trying to use the SaveAs class, and I've created a minimal project to test it, based entirely on Erel's example here: https://www.b4x.com/android/forum/t...list-of-other-related-methods.129897/#content
I'm not using B4XPages so I have used the GetBA code given in the link above.
My project errors in the FileHandler class, in the sub GetBA (line 39) because the variable "cls" has the value [dateutils=null, ion=java.lang.Object@d64f2c6, main=null, starter=null, xuiviewsutils=null], and it does not contain the string "class".
I'm using B4A version 13.10, and I have made the manifest file additions described here: https://www.b4x.com/android/forum/t...e-and-load-external-files.132731/#post-838166
I'm hoping someone can please tell me what is wrong, because I'm stumped. Thanks in anticipation.
I'm not using B4XPages so I have used the GetBA code given in the link above.
My project errors in the FileHandler class, in the sub GetBA (line 39) because the variable "cls" has the value [dateutils=null, ion=java.lang.Object@d64f2c6, main=null, starter=null, xuiviewsutils=null], and it does not contain the string "class".
I'm using B4A version 13.10, and I have made the manifest file additions described here: https://www.b4x.com/android/forum/t...e-and-load-external-files.132731/#post-838166
I'm hoping someone can please tell me what is wrong, because I'm stumped. Thanks in anticipation.
FileHandler:
Sub Class_Globals
Private ion As Object
Type LoadResult (Success As Boolean, Dir As String, FileName As String, RealName As String, Size As Long, Modified As Long, MimeType As String)
End Sub
Public Sub Initialize
End Sub
Public 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"))
File.Copy2(Source, out)
out.Close
Return True
End If
Return False
End Sub
Private Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub