Android Question close all activity at once

Roberto P.

Well-Known Member
Licensed User
Longtime User
you can close all the activity open at once?

how do I close a series of activity, open one after another, to return to the main activity?

otherwise the user must close one activity at a time.

thanks
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
You can always call StartActivity(Main) to bring it to front.


ok, but open activity are not closed! I would like to close all open activity - automatically - and return to the main.

I think to a cycle that closes all open activity, in the background, and the program returns automatically to the main or even with the startActivity.

I hope I was clear.

thanks your
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
In such cases I consume the back key in activity_keypress, start from there the desired activity, and use activity.finish. Hope this helps.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
I explain better with a picture.
Thank you
 

Attachments

  • activities.png
    activities.png
    25.7 KB · Views: 500
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Thanks to,
audition this solution to see how it behaves with a bit of open activities.
Greetings
 
Upvote 0

cimperia

Active Member
Licensed User
Longtime User
I had a similar problem. I wrote the following bit of Java code to make sure that all activities were closed once my app was back to Main:

B4X:
Sub btnHome_Click
   NativeJava.RunMethod("GoHome", Null)
End Sub

#If JAVA
   public void GoHome()
   {
     import android.content.Intent;
       
     Intent intent = new Intent(this, main.class);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
     startActivity(intent);

     return;
   }
#end if
 
Upvote 0
Top