CallSubDelayed2 issue/question

NJDude

Expert
Licensed User
Longtime User
This is the scenario, a notification will open an activity and from that activity the Main activity can be accessed, however, that is not working under certain circumstances.

This Works:

1- Run the app

2- Open the notification and click on "Test Notification" (this will open an activity)

3- Click the "Click Me" button

4- Repeat steps 2 and 3

You can keep doing that until you pass out. :D


This DOES NOT Work:

1- Exit the app

2- Open the notification and click on "Test Notification"

3- Click the "Click Me" button

4- Repeat step 2 and you will see that now the activity containing the "Click Me" button doesn't appear.

Is this how CallSubDelayed2 works or it's a bug?, Is there a workaround or it's just not possible?

This is part of an app I'm writing and noticed that, the attached project contains the barebone routines.

Any help or explanation will be appreciated.
 

Attachments

  • CallSubDelayedIssue.zip
    7.9 KB · Views: 301

Erel

B4X founder
Staff member
Licensed User
Longtime User
This issue is not related to CallSubDelayed. It is related to the way Android handles tasks and the activities stack.
When you destroy the main activity and then start the second activity a new task is created. Later when you press on the notification Android returns to the last state in this task which is the main activity. It does make sense to return the user to the last point and not to the first point.
 
Upvote 0
Top