Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling finish() doesn't finish the activity

I want to finish my activity when it pauses for specific reasons. Up till recently my code was working perfectly but recently the finish() method stopped doing its job for some reason. Also, when the finish() method is called, I get the following LogCatmessage:

12-31 18:01:23.445: W/ActivityManager(481): Duplicate finish request for ActivityRecord{42465370 u11 "myapplicationpackage"}

Could someone help me out with this?

OnPause() method

@Override
protected void onPause() {
    super.onPause();
    finish();
}
like image 809
Tanuj Nayak Avatar asked Jan 01 '13 02:01

Tanuj Nayak


1 Answers

You can check if your activity is finishing already by calling if (isFinishing()){}, and calling finish only if it is not. Alternatively you might want to specify android:noHistory="true" on your activity in manifest file, which will actually finish your activity once user navigates away from it.

like image 51
marcinj Avatar answered Sep 29 '22 11:09

marcinj