开发者

How to completely finish my activity, and after activity.finish no further code will execute?

I want to completely finish my activity, and after activity.finish no further code will execute?

Example:

Intent scoringOpponentTeam = new开发者_JAVA百科 Intent(this,TestActivitySecond.class);
startActivity(scoringOpponentTeam);
this.finish();
Log.i("after Finish Called", "after Finish Called--------"+"after Finish Called");

In above example, I want that no Log.i() line will execute.


When you are calling finish(), Android will let your code in the specific block after the finish() call execute, and that is why the log message appears. A simple return statement after the finish() call is the solution.

However, there is no need for you to explicity "kill" your Activity since Android handles this perfectly on its own.


this.finish();
return;


You need a return statement after your this.finish();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜