How to finish current activity in Android

前端 未结 8 1441
长发绾君心
长发绾君心 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:43

    If you are doing a loading screen, just set the parameter to not keep it in activity stack. In your manifest.xml, where you define your activity do:

    
    

    And in your code there is no need to call .finish() anymore. Just do startActivity(i);

    There is also no need to keep a instance of your current activity in a separate field. You can always access it like LoadingScreen.this.doSomething() instead of private LoadingScreen loadingScreen;

提交回复
热议问题