Android Question Starting more activities one after the other (stack?)

Dario126

Member
Licensed User
Longtime User
In my main activity inside Activity_Create I start three other activities. There is desired order to start them, first should be "Intro" activity, then "Eula" activity, and finally some activity which is "base" form/activity for app.

If I put them in code by that sequence, they appear in revers order: base-eula-intro (almost like they are stacked on top of each other)...

Probably b4a start first one (intro) and but it thus not wait for this one to finish and return to same code position, but starts second and third? Last one is visible to user until is closed, then secodn continues, etc ..

Is that correct?

I solved this be reverse order start sequence, but I'm wondering if this is right way to do it ?
 

klaus

Expert
Licensed User
Longtime User
In my main activity inside Activity_Create I start three other activities.
This sounds strange to me.
As a first answer I would say it's not the right way.
But to give a concrete answer if your management is the right way, you need to show us your code.
 
Upvote 0

Dario126

Member
Licensed User
Longtime User
This sounds strange to me.
As a first answer I would say it's not the right way.
But to give a concrete answer if your management is the right way, you need to show us your code.

This is code ..
B4X:
Sub Activity_Create(FirstTime As Boolean)

    'SERVICE1 sa GPS-om  i settingsima
    StartService(Service1)   


    File.Delete(File.DirInternal,"SETTINGS")

   
        'START BROWSER FORM
        StartActivity(Browser)
       
        'INTRO & EULA
        If FirstTime Then

            'EULA
            If Not(File.Exists(File.DirInternal,"SETTINGS")) Then
                StartActivity(Eula)
            End If       
           
            'INTRO
            StartActivity(Intro): DoEvents
                   
        End If

   
End Sub

and now (like above) I first see Intro activity, then Eula activity, and finally Browser activity.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
That's what I suspected, in your code you start the different Activities directly from the first one.
If you start several activities one after the other they will start one after the other, the latest ones replacing the previous ones.
That's how Android works.
You might have a look at the chapters below in the Beginner's Guide.
9 Process and Activity life cycle
13.2 Program with 3 Activities (ThreeActivityExample.b4a)
 
Upvote 0

Dario126

Member
Licensed User
Longtime User
Yap, I have forget about that ..

But, those examples you referring means I should start only one activity, and from that one before closing start second, and so on .. ?

That way code gets less "readable" through different modules/activities, and there is harder to implement some different scenarios/sequences. Isn't there a way that I could do something like this:

StartActivity(Intro)
Pause
StartActivity(EULA)
Pause
StartActivity(Browser)
Pause


Now when I look at it, and consider Your reminder, I presume that's not possible :=(
Any how, thank You ..
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…