Killing activity on Android does not clear memory?

I have a game on Android.

basically this structure is similar to lunarlander

I started my activity using a layout to run a class.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

 <my.darling.gameView
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/>

</FrameLayout>

When I clicked on the house, I can return to my game every time. I always close the stream and create a new one.

The problem occurs when I press BACK botton.

I think my game is over. but after 4 times "click game" → "click" BACK "

An error message appears - "unexpectedly stopped"

I redefine the function: onPause()and is called finish(). But this is still happening.

Can anybody help me?

+3
source share
1

:

UIthread. , BACK.

, , Bitmap.

, , BACK , VM - .

I, , .

:

protected void onPause()
{
    super.onPause();
    System.gc();
}

Bitmap android. GC, . .

Bitmap.recycle(), Bitmap.

http://mobi-solutions.blogspot.com/2010/08/how-to-if-you-want-to-create-and.html

http://code.google.com/p/android/issues/detail?id=8488

+4

Source: https://habr.com/ru/post/1771471/


All Articles