android - How to close all the activities of my application? -


I have found an application with many activities, for example:

Activity 1 - & gt; ; Activity 2 - & gt; Activity 3 - & gt; Activity 4

And I would like to stop all activities from any activity and return back home.

You can get it by using BroadcastReceivers :

  • Create BaseActivity in this way:
      extends the public square base activity activity {Private Killrescrew mKillReceiver; @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); MKillReceiver = New KillReceiver (); Register Receiver (M. Kail receiver, Intent filter.cent ("kill", "Spartan !!!")); } @ Overhaired Protected Zero Destroy () {Super. Onesteroy (); UnregisterReceiver (mKillReceiver); } Private Final Class KillReceiver Broadcast Receiver Expands {@ Override Public Records on Receive (Context Reference, Intention Intention) {Finnish ();   
    • Boost your activities that code base activity .
    • Whenever you want to clear the stack:
        intent = new intent ("kill"); Intent.setType ("Spartan !!!"); SendBroadcast;   


Comments