How to finish current activity in Android

前端 未结 8 1443
长发绾君心
长发绾君心 2020-11-28 03:19

I have an Android application. I am making a loading screen with a progress bar.

I entered a delay in the onCreate method. When the timer finishes, I want to finis

8条回答
  •  我在风中等你
    2020-11-28 03:51

    I found many answers but not one is simple... I hope this will help you...

    try{
        Intent intent = new Intent(CurrentActivity.this, NewActivity.class);
        startActivity(intent);
    } finally {
        finish();
    }
    

    so, Very simple logic is here, as we know that in java we write code that has some chances of exception in a try block and handle that exception in catch block but in finally block we write code that has to be executed in any cost (Either the exception comes or not).

提交回复
热议问题