Call this in your onDestroy() on your outer-most layout to free up memory:
public void unbindDrawables( final View v ) { if( v.getBackground() != null ) { v.getBackground().setCallback( null ); } if( v instanceof ViewGroup && !( v instanceof AdapterView ) ) { for( int i = 0; i < ( (ViewGroup) v ).getChildCount(); i++ ) { unbindDrawables( ( (ViewGroup) v ).getChildAt( i ) ); } ( (ViewGroup) v ).removeAllViews(); } }
Helps with memory leaks in Android, especially if you have an app that switches activity screens a lot.

Post a Comment