Buggy code:
public class Upload_b extends Activity { private static final int PICK_IMAGE = 1 ; Button btnCamera ; Button btnUpload ; Button btnYes ; Button btnNo ; ImageView imgFavorite ; Bitmap bitmap ; boolean isFilterPhoto ; Bitmap finalimg ; private static final float INITIAL_ITEMS_COUNT = 3.5F ; private LinearLayout mCarouselContainer ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } OnClickListener save = new OnClickListener ( ) { @ Override public void onClick ( View v ) { } } ; OnClickListener back = new OnClickListener ( ) { @ Override public void onClick ( View v ) { } } ; @ Override protected void onActivityResult ( int requestCode , int resultCode , Intent data ) { } protected void refresh ( ) { final DisplayMetrics displayMetrics = new DisplayMetrics ( ) ; getWindowManager ( ) . getDefaultDisplay ( ) . getMetrics ( displayMetrics ) ; final int imageWidth = ( ( int ) ( ( displayMetrics . widthPixels ) // ( Upload_b . INITIAL_ITEMS_COUNT ) ) ) ; final HashMap < String , Filter > map = ( ( HashMap < String , Filter > ) ( loadSerializedObject ( new File ( "//sdcard//save_object.bin" ) ) ) ) ; final ArrayList < String > testArray = new ArrayList < String > ( ) ; File dir = new File ( ( ( Environment . getExternalStorageDirectory ( ) ) + "//Pictures//peel" ) ) ; File [ ] filelist = dir . listFiles ( ) ; int count = 0 ; for ( File pic : filelist ) { if ( count > 3 ) { break ; } testArray . add ( pic . getAbsolutePath ( ) ) ; count ++ ; } ArrayList < OnClickListener > listeners = new ArrayList < OnClickListener > ( ) ; for ( int i = 0 ; i < ( testArray . size ( ) ) ; ++ i ) { final int idx = i ; OnClickListener filter = new OnClickListener ( ) { @ Override public void onClick ( View v ) { Log . v ( "v" , ( "map<seq2seq4repair_space>size:" + ( map . size ( ) ) ) ) ; String path = testArray . get ( idx ) ; Filter f = map . get ( path ) ; <START_BUG> Log . v ( "lalala" , f . toString ( ) ) ; <END_BUG> BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inPreferredConfig = Config . ARGB_8888 ; Bitmap bitmap1 = BitmapFactory . decodeFile ( path , options ) ; Bitmap filtered = ImgProcessor . applyFilter ( bitmap , f ) ; imgFavorite . setImageBitmap ( filtered ) ; finalimg = filtered ; bitmap1 = null ; System . gc ( ) ; } } ; listeners . add ( filter ) ; } ArrayList < ImageView > imageItems = new ArrayList < ImageView > ( ) ; ImageView imageItem ; for ( int i = 0 ; i < ( testArray . size ( ) ) ; ++ i ) { imageItem = new ImageView ( this ) ; imageItem . setBackgroundResource ( shadow ) ; BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inPreferredConfig = Config . ARGB_8888 ; Bitmap bitmap1 = BitmapFactory . decodeFile ( testArray . get ( i ) , options ) ; imageItem . setImageBitmap ( bitmap1 ) ; imageItem . setLayoutParams ( new LinearLayout . LayoutParams ( imageWidth , imageWidth ) ) ; imageItem . setOnClickListener ( listeners . get ( i ) ) ; imageItems . add ( imageItem ) ; mCarouselContainer . addView ( imageItem ) ; bitmap1 = null ; System . gc ( ) ; } } private String saveImage ( Bitmap finalBitmap ) { } public Object loadSerializedObject ( File f ) { } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } }

Fix:
Log . v ( "lalala" , ( f == null ? "null" : f . toString ( ) ) ) ;