If we call the acitivty.finish() and there are some lines of code below that. will that be executed once the finish() has been called? or ignored?
Asked
Active
Viewed 187 times
1
-
https://stackoverflow.com/q/2590947/8089770 – Vidhi Dave Apr 10 '18 at 06:13
1 Answers
7
If we call the acitivty.finish() and there are some lines of code below that. will that be executed once the finish() has been called?
Yes
Because acitivty.finish()
is not an abort
CHECK this Example
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e("TEST", "BEFORE FINISH");
finish();
Log.e("TEST", "AFTER FINISH");
Log.e("TEST", "AFTER FINISH");
}
RESULT

Gowthaman M
- 8,057
- 8
- 35
- 54

AskNilesh
- 67,701
- 16
- 123
- 163
-
But if i use intent before finish and add this lines after finish.. will it work? – Vidhi Dave Apr 10 '18 at 06:14
-
1@VishvaDave After calling finish() your activity will not be immediately finished but only planned to be 'finished'. So execution of code will continue – AskNilesh Apr 10 '18 at 06:16