Android Studio - How to ( close, quit, exit, kill, etc.) an application -


this question has answer here:

firstly, i've tried solutions issue can not find solution.

question: when user press exit button in application want kill application. there few methods finish(); or system.exit(0); if use on mainactivity, work. want this, if mainactivity or activity or b activity doesnt matter activty when press exit button kill application , go phones menu.

this trick

finishaffinity(); 

check deails: api description

finish activity activities below in current task have same affinity. typically used when application can launched on task (such action_view of content type understands) , user has used navigation switch out of current task , in own task. in case, if user has navigated down other activities of second application, of should removed original task part of task switch.

note finish not allow deliver results previous activity, , exception thrown if trying so.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -