4

Friends In my activity i have placed finish() inside onBackpressed(), Still sometimes it is not finishing or destroying the activity.. What will be the issue?

Manse
  • 37,765
  • 10
  • 83
  • 108
Ranjit
  • 209
  • 5
  • 12

4 Answers4

5

super.onBackpressed() will do the finishing thing for you, so dont comment this line after overriding this function.. add your extra functionality in this function if you have any...

Farhan
  • 13,290
  • 2
  • 33
  • 59
1

finish() just tells the activity to do what it needs to do to finish, eg. shutdown, call on onPause, report result to parent, etc. It doesn't do an exit() call or anything.

You should return after the finish() call.

also, see this question: about finish() in android

Community
  • 1
  • 1
Altaaf
  • 527
  • 3
  • 11
0

you can also use finish(); inside onBackPressed();

please try this...

Goofy
  • 6,098
  • 17
  • 90
  • 156
-1

sometimes finish() method not supported. your OnBackPressed() method should have @Override notation. bt this notation only supported in API level greater than 5.

for me it works.

mita
  • 15
  • 3