Using CallSubDelayed

mjas

Member
Licensed User
Longtime User
Hi Erel,

Sorry about posted this in the wrong place.
I'm a newbie with B4A and forums too.

I am starting a new project and using your example to create several activities, and switching them with "CallSubDelayed" and everything goes fine, but the big issue is:
Because I'l never close anyone of the activities, only switch from one to another, when I am in the Main activity and press the Back button, the Aplication does'n finish, only finishes the Main activity and goes to the next activity in the stack (the last one I opened) and pressing the Back button again do the same (close this one and goes for the next one) and only after pressing the Back button the same number of times like the activities i have finally it goes out for the Home screen.
Even if I trap the Back button event in Main activity and use "ExitApplication()" it does the same like before but throws an error in Log window:
"Got RemoteException sending setActive(false) notification to pid 557 uid 10036" because this pid is the Main activity just closed.
Any idea how this can be fixed?

BTW: I tried to do this in Manisfest.xml:
SetActivityAttribute(name of activity , android:noHistory, "true")
but this doesn't fix this behaviour, only resets each view to the initial state each time it is activated.

Thank you for any help.

And to say :sign0098:
 

mjas

Member
Licensed User
Longtime User
Erel, thanks for your answer.:)

But when call Activity.Finish() at the Main activity the App doesn't go to the background, it displays the next activity that is on the queue, the last one that was called with CallSubDelayed.

Like a solution I added a variable in each activity that finishes it (Activity.Finish) when it goes to the resume state.

But that is not good because when closing the Main activity, it goes for each of the 10 activities the App has, closing each one at a time until it shows the Home screen of the device again.:mad:

Here is the code:
B4X:
Main module:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        If Msgbox2("Do you want to close?", "", "Yes", "", "No", Null) = DialogResponse.POSITIVE Then
          another activity.finished=True
         and another activity.finished=True
         ............................
         last activity.finished=True
         Activity.Finish()
            Return True
   .................................

In each Activity module:
Sub Activity_Resume
   If finished Then
      finished=False
      Activity.Finish()
   End If
End Sub
Do you know another way to fix this?

Thank you very much!
 
Upvote 0

mjas

Member
Licensed User
Longtime User
;)Thank you very much for your help.
I appreciated it.
Keep on with this good work. :sign0098:
 
Upvote 0
Top