Ranjit
Ranjit

Reputation: 209

Why Activity is not finishing or destroying after calling finish() in onBackPressed()?

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?

Upvotes: 4

Views: 4821

Answers (4)

mita
mita

Reputation: 15

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.

Upvotes: -1

Goofy
Goofy

Reputation: 6128

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

please try this...

Upvotes: 0

Altaaf
Altaaf

Reputation: 527

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

Upvotes: 1

Farhan
Farhan

Reputation: 13390

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...

Upvotes: 5

Related Questions