Changing activity in android clears the memory needed for the previous activities?

前端 未结 3 1674
青春惊慌失措
青春惊慌失措 2021-01-15 16:04

I am developing a multi level game, where each level is a new activity.

I want to know, if i change the activity like

Intent myIntent = new Intent(ge         


        
3条回答
  •  忘掉有多难
    2021-01-15 16:51

    You need to call finish() for the activity (or activities) that you no longer want to be active. You can simply call it right after starting the new activity:

    Intent myIntent = new Intent(getBaseContext(), Level3.class);
    startActivity(myIntent);
    finish();
    

    Otherwise, the previous activity will remain on the activity stack.

提交回复
热议问题