Android Question How to close all remaining activities on ExitApplication

kkolle

Member
Licensed User
Longtime User
Hallo,

We have a problem with our activity stack.
The normal way is navigate from main to message and from message to newmessage by using startActivity(message) an startActivity(newmessage).
Closing every activity with activity.Finish works fine.

But by using the notification bar an click on the notification, while the app last activity is newmessage, the main activity pop up.
On close the application by using ExitApplication, the both activities message and newmessage show up.

We don´t want the user to always go back to their last used activity.

So my main question is: Is there a better way to close the application and all of its activities?
 

ilan

Expert
Licensed User
Longtime User
But by using the notification bar an click on the notification

when you set the notification ".SetInfo("blabla", "blabla...", Main)"
have you set the correct activity that should be started when user click on the notification?
 
Upvote 0

kkolle

Member
Licensed User
Longtime User
We set the notitication text to "you have x tasks and y messages" so we build one notification for both infos and set the Activity to Main.
On main the user get an overview about the task and message count and his aktive task.

The problem is that we only set main as activity for the notification. But the user can go to the notification from any activity an click on it.
So if he is in task or messages and select the notification from notification center he jumped back to main an the task/message activity keeps alive in background.

And on ExitApplication or even on Activity.Finish in the main the background activitys pop up and stay alive.
And we want to close all activitys in the activity-stack.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i dont understand why you have only 1 notification. if activity task created the noti then you should create a noti with activity task.

anyway what you could do if you want to use only 1 notification is on each activity finish (for example in activity task) create a file to dirinternal with the name task.txt
and on main_resume event check if that file exists if true start activity task but dont forget to delete the file if it exists in main_resume sub
otherwise on every app start you will be moved to task activity.

do the same for activity message (create file in activity_pause msg.txt)

and on main resume check also if that file exists if true start activity message
 
Upvote 0
Top