How exactly does the internal message queue, I guess it would be called, in B4A work? I've got some activities with things like this I need to do as well and wondered the best/safest way to call it. When you call startactivity your original activity that called it should be paused, but that appears to be a queued message or does it take place right when the sub finishes? Same thing with Activity.Finish? It is supposed to be queued too right? So, couldn't he just do:
sub btn_next_Click
Activity.Finish
StartActivity("activity_2")
end sub
Ending the activity would remove the views and no references to the bitmaps, so no need to set to null. In my tests here I made a test sub executing a toastmessage and the sub still finishes(Shows the message) and the Activity immediately closes.
Or, perhaps to enhance the flow he could set them to null before so it isn't trying to do it while loading the activity.
sub btn_next_Click
imageview1.bitmap=null
imageview2.bitmap=null
StartActivity("activity_2")
Activity.Finish
end sub
Seems unnecessary to set to null though since Finishing the Activity does the same thing. And the delay is most likely always going to be there since no matter how it is done the end result of one activity closing and another opening is occurring.
I haven't tested it, but what happens behind the scenes if a DoEvents is stuck in there? Like after StartActivity would it pause our Activity and not allow the sub to finish. Or if after Activity.Finish in my first example would it not Start the next Activity (This one I did test and my ToastMessage still shows...so what does DoEvents accomplish in that case? Or, is there code in there to prevent stuff like this or deadlocks?) Is it safe to finish first like this or is there cases where it may kill the activity before the sub finishes?
At what point is Activity_Pause fired too? Is it queued, is it right when StartActivity is called? Coming from Windows programming I wonder if events here are the same. Like if I change text of an edit box in its TextChanged event I usually add code to prevent endless looping. Does B4A fire the event right when I change that text like Windows? Is it queued? Does it call it like a Recursive Function?