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

前端 未结 3 1668
青春惊慌失措
青春惊慌失措 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条回答
  •  Happy的楠姐
    2021-01-15 16:32

    since you are using an activity/level design, just add a check if your activity is finishing in your onPause method, and null all your references to the current level, that way the GC will know that your level object should be released, and it will release it as soon as possible.

    @Override
    public void onPause(){
          super.onPause();
          if (isFinishing()){
             levelObject = null;
    }
    

    }

提交回复
热议问题