Exemplo n.º 1
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   // Partly from http://stackoverflow.com/a/5069354
   unbindDrawables(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0));
   System.gc();
 }
Exemplo n.º 2
0
 // Code from Stackoverflow to reduce memory problems
 // onDestroy() and unbindDrawables() methods taken from
 // http://stackoverflow.com/a/6779067
 protected void unbindDrawables(View view) {
   if (view.getBackground() != null) {
     view.getBackground().setCallback(null);
   }
   if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
     for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
       unbindDrawables(((ViewGroup) view).getChildAt(i));
     }
     ((ViewGroup) view).removeAllViews();
   }
 }