title: BitmapFactory.decodeFile and ImageView strange thing in Android
body: <p>I have strange problem - it occurs on xperia (android 4.0.3) but not on samsung S plus (2.3.6). In application i'm using google maps APIv2 with support library (in another activity. Not sure if matters).</p>
  
  <p>I think i have narrowed problem to:</p>
  
  <pre><code>private Bitmap bitmap;
  private String st;
  private static final String PHOTO_DIR = "photodir";
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      [...]
      st = Environment.getExternalStorageDirectory().toString() + "/" + PHOTO_DIR  + "/test.jpg";
      bitmap = BitmapFactory.decodeFile(st);
      ImageView im = (ImageView) findViewById(R.id.imv_Photo);
      im.setImageBitmap(bitmap);
      [...]
  </code></pre>
  
  <p>This works as expected. But this:</p>
  
  <pre><code>@Override
  public void onClick(View v)
  {
      try
      {
          ImageView im = (ImageView) findViewById(R.id.imv_Photo);
          String st = Environment.getExternalStorageDirectory().toString() + "/" + PHOTO_DIR  + "/test1.jpg";
          Bitmap bitmap = BitmapFactory.decodeFile(st);
          im.setImageBitmap(bitmap);
      }
      catch (Exception e)
      {
          // null
      }
  }
  </code></pre>
  
  <p>hangs the application (despite of try/catch block!) even with im.setImageBitmap(bitmap) removed. When i comment out BitmapFactory.decodeFile problem dissappears. Even worse xperia unmounts sd-card when plugged to usb and i don't know how to write pics to phone memory yet, so i'm unable to check log (btw: is there a way to get log later?)</p>
  
  <p>When i remove code from onCreate(), onClick() works exactly once. I tried to set bitmap = null, and setImageBitmap(null) before decoding, but it doesn't help.</p>
  
  <p>This seems very strange to me as samsung has no problem with same code.</p>
  
  <p>Is there any solution or maybe i'm doing something wrong?</p>