Android Question Difference between CallSub3 and CallSubDelayed3

D

Deleted member 103

Guest
Hi,

In this example, I show a difference between CallSub3 and CallSubDelayed3, and I want to know if it's normal or if it's a B4a error.

1) If I start the Activity-2 with the button "Button1_Click", then after 5 seconds the app stops at Activity-2.

2) But if I start the Activity-2 with the button "Button2_Click", then after 5 seconds the app goes back to Activity-1.

Question: is this normal or is it a mistake?
 

Attachments

  • B4a-Example -1.zip
    10.2 KB · Views: 284

LucaMs

Expert
Licensed User
Longtime User
E' normale perché tu posticipi l'esecuzione di ShowProgressDialog, che viene effettuata dopo la scadenza e quindi riapre la Main.


It's normal because you postpone the ShowProgressDialog execution, which is done after and reopen the Main.


See the log.
 
Upvote 0
D

Deleted member 103

Guest
E' normale perché tu posticipi l'esecuzione di ShowProgressDialog, che viene effettuata dopo la scadenza e quindi riapre la Main.


It's normal because you postpone the ShowProgressDialog execution, which is done after and reopen the Main.


See the log.
No, I think the function "CallSubDelayed3" should wait until the Activity-1 is active, or so I imagined it.
 
Upvote 0
D

Deleted member 103

Guest
CallSubDelayedX waits for the end of the sub that contains it.
Ok, then I got it wrong.
I thought it was behaving like the function "CallSubDelayedPlus",
because that's waiting, after the time is up, until the activity is active again.
 
Upvote 0
D

Deleted member 103

Guest
It is a mistake to call CallSubDelayed together with StartActivity. Both of these calls will try to start an activity.

If you call a sub in the main activity after it was paused then it will be resumed.
My example is just for demonstration, I have a completely different case.

In my case, I start a Bluetooth connection, as it may take a little longer, the user launches a second activity.
If now the Bluetooth connection does not come, then again the main activity is started and the user is somewhat confused.
 
Upvote 0
D

Deleted member 103

Guest
Move everything that you can to a service (starter service is good). It will be simpler.
It's all in the starter service, only the sub "ShowProgressDialog" is in the main activity.
All I have to do is replace the CallSubDelayed function with the CallSub function, at least I hope so. :)
 
Upvote 0
Top