Finish old activity and start a new one or vice versa

后端 未结 7 2118
轮回少年
轮回少年 2020-12-02 15:16

I know, that I get the same result with both code snippets

finish();
startActivity(newActivity);

and

startActivity(newActiv         


        
相关标签:
7条回答
  • 2020-12-02 15:48

    I usually do startActivity() before finish() as I think that'd make sure the new screen comes out before the previous goes out.

    I have a login page in my app. After user login successfully, the login activity is gone and main activity is up. It works fine in the Android 4.

    Today I wanted to rewrite it in Material design. However, I got a big problem. New Android studio creates blank activity with material design which I think takes many resources. The same process, but I got the error

    11-26 18:20:44.450 18397-18397/? I/Choreographer: Skipped 42 frames!  The application may be doing too much work on its main thread.
    11-26 18:20:44.485 18397-18408/? I/art: Background partial concurrent mark sweep GC freed 2864(191KB) AllocSpace objects, 4(43MB) LOS objects, 13% free, 100MB/116MB, paused 8.056ms total 39.767ms
    

    It said my apps takes many resources when mainActivity starts in my phone logcat. I have nothing in mainActivity just that it is the default Material Design layout.

    I reversed the order and now it works without error on my phone.

    0 讨论(0)
提交回复
热议问题