It goes well if I use it in a small test program (with B4XPages) -> B4A program opens a "system" window and requests user's agreement for writing the file in Download directory.
If I move this code in a large program with several pages, the "ion-Event" is never fired after the opening and the agreement for writing the file
Launching code (placed in B4XMainPage) is as follows :
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)
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 = Me
Return jo.RunMethod("getBA", Null)
End Sub
"ion" is a global variable declared as an Object.
Nothing appears in the Log after the "StartActivityForResult(intent)" instruction. Program is waiting ?????
But a zero byte is created in the Download directory (which is the purpose of the Intent if my understanding is right).
@Erel
I restart from my running well test program and I copy inside a part of my large (not running) program.
Unfortunately, event is not fired
One of the main difference is that I added a B4XPage.
Could that be the issue (the system does not know where to return ????) ?
@Erel and @DonManfred
Thanks for your help
I guess I found the issue : my "Save File" call was just launched before "ExitApplication"
And Event was fired too late !