Release Memory of Particular Activity when it is Destroyed

前端 未结 7 1533
说谎
说谎 2020-12-15 05:38

I have a launcher Activity that load and resize big bitmap as it\'s background when it opens.

Whenever hit the back button, the Activity is

7条回答
  •  有刺的猬
    2020-12-15 06:07

    Add following code for it

    @Override
    protected void onDestroy() {
        //android.os.Process.killProcess(android.os.Process.myPid());
    
        super.onDestroy();
        if(scaledBitmap!=null)
                {
                    scaledBitmap.recycle();
                    scaledBitmap=null;
                }
    
         }
    

提交回复
热议问题