Facing problem while closing application here is a simple solution.
Now no need to use the lengthy way like using broadcast receivers.
Scenario :- if you have an application in which multiple activities are opened and you want to close your application from any of the activity. so here is a simple solution.
finishAffinity();
this single method closes all the activities and most interestingly does not matter from which activity you have called it it will just close every activity create before it.
Every functionality comes with a coast so here you have not to pay much but you need to keep your application on ro above 4.1
here is a simple implementation for the above code link for github
If you want to add support for prior 4.1 devices you can use the broadcast receiver method.
if you require any info on this let me know in comments.
happy coding :)
0 Comment(s)