android - how to manage background images without memory leaks?
<p>Good morning,</p>

<p>in the process of writing my first android app, so please be patient.</p>

<p>I want to have background images for the activities I use. My first approach to add it simply to the layout of the activities,</p>

<pre><code>....
&lt;ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/desc_background"
    android:scaleType="centerCrop"
    android:src="@drawable/background"
    android:tint="#dd000022" /&gt;
....
</code></pre>

<p>unfortunately this seems to lead to a memory leak when I call certain activities repeatedly. Finally I got hold of and found the reason why here <a href="http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/" rel="nofollow">Avoid memory leaks on Android</a> </p>

<p>My next thought would have been to do what Romain in above mentioned article calls a " very fast and also very wrong" solution - saving the bitmap in a static field or in the Application object.</p>

<p>I found various articles on this topic yet none of them seems to be aware of Romains point. Also I am not clear how to implement Romains solution.</p>

<p>Any hint how to handle images in android without running into memory leaks would be highly appreciated. </p>

<p>Thanks a lot</p>

<p>martin</p>
