Android Tutorial Using CallSubDelayed to interact between activities and services

Derek Jee

Active Member
Licensed User
Longtime User
It will run before activity_resume.
Hi Erel

Mine is not playing nicely. I put the custom sub in where I populate a variable of the second activity from the parameter I pass from the first. I then run a sub from my activity_resume which should already have the populated variable which I use in subsequent subs. I put a log entry in on the custom sub and the activity_resume and the activity_resume runs first and not the way you suggested.. You can see the log entries state 1 and 2 in the order I think they should go but the log registers 2 first..

My sub looks like this
B4X:
Public Sub OpenFix(isTrue As Boolean)

    IsFix = isTrue
    Log("1 - " & IsFix)

End Sub

and my activity_resume is this

B4X:
Sub Activity_Resume

    Log("2 - " & IsFix)
    If IsFix = True Then
   
        LoadData
        Return

Etc

What am I going wrong?

Kind regards

Derek.
 

Derek Jee

Active Member
Licensed User
Longtime User
Here it is Erel..
 

Attachments

  • Test.zip
    1.9 KB · Views: 581

Derek Jee

Active Member
Licensed User
Longtime User
Load data is used to load persisted data in a database and must (also) be run from the activity resume.. I can do both I guess..

Thank you for your time Erel
 

Derek Jee

Active Member
Licensed User
Longtime User
I have a few activities which the user will switch between and need to save the data and load the data on switching. Where is a better place to load when opening/resuming an activity? I do call a sub to load the data from there, not just load the data from activity_resume..
 

LucaMs

Expert
Licensed User
Longtime User

If you load data calling a sub from Resume or you load data inside Resume, it is the same.

I think Resume is the right place.


[P.S. if you can load just the data changed it is better, of course]
 
Last edited:

ArminKH

Well-Known Member
It seems that for some properties the OS needs some more time to refresh the view(for example) before executing the next instruction.
Otherwise the next instruction is executed before the refresh
this is not relevant to b4a,this is how android works
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…