Android Question Event not fired with SaveFile function

CR95

Active Member
Licensed User
I am using the "Save File" code from Erel's sample
https://www.b4x.com/android/forum/t...list-of-other-related-methods.129897/#content

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)
With :
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
Any idea what is happening ?
 

CR95

Active Member
Licensed User
Thanks Erel for your help
Is ion a global variable? What do you see in the logs?
"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).

My code is a copy of this example. The difference is that I used it in the B4XMainPage (in the example, the code is in a separate class)
 
Upvote 0

CR95

Active Member
Licensed User
@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 ????) ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top