-2

The finish() method sends me back to the main activity, rather than terminating the app. Any suggestions?

DarkAjax
  • 15,955
  • 11
  • 53
  • 65

2 Answers2

3

I guess it works, because finish() is not in any way intended to terminate app. There's no such concept on Android anyway. What finish() does is, as you see, terminate activity. See docs

In general it usually helps to understand what you doing, so RTFM on "misbehaving" methods prior asking sounds like good habit to quickly solve most of "does not work" problems like this one.

There's SO's question you should follow as well: Is quitting an application frowned upon?

Community
  • 1
  • 1
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

Finish terminates an activity, not an application. To terminate an application, call finish() on the entry activity that started it (thus clearing the stack).

Mgamerz
  • 2,872
  • 2
  • 27
  • 48