title: Memory/Allocation errors when setting ImageButton from Camera Photo
body: <p>I am trying to take a photo from the phones camera and place in it in a ImageButton as part of a Profile activity including all users details, and then save the image as shared pref.</p>
  
  <p>If I use the following code the ImageButton simply does not update: </p>
  
  <pre><code>    protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
              // method checks data returned form camera via startActivityForResult
              super.onActivityResult(requestCode, resultCode, data);
  
                  Runnable runnable = new Runnable(){@Override
                      public void run() {
                          handler.post(new Runnable(){
  
                              @Override
                              public void run() {
                                  Bundle extras = data.getExtras();
                                                              photo = (Bitmap) extras.get("data");
  
                                                  takeAndSetPhoto.setImageBitmap(photo);
                                  Toast.makeText(getBaseContext(), "Image set to profile!",
                                          Toast.LENGTH_SHORT).show();
                              }//edn inner run
  
  
                          });//end new runnab;e
  
                      }
  
                  };
                  new Thread(runnable).start();
  
              }//end if result OK     
          }// end onActivity
  </code></pre>
  
  <p>Alternatively the image DOES load if I use this method but I get erros:</p>
  
  <blockquote>
    <p>Allocation fail for scaled Bitmap
    Out Of Memory 01-03 10:13:06.645: E/AndroidRuntime(30163):
    android.view.InflateException: Binary XML file line #18: Error
    inflating class </p>
  </blockquote>
  
  <p>The code is using Uro for phot taken:</p>
  
  <pre><code>                    public void run() {
                          Bundle extras = data.getExtras();
                          Uri photoShot = data.getData(); view
                          takeAndSetPhoto.setImageURI(photoShot);
                          Toast.makeText(getBaseContext(), "Image set to profile!",
                                  Toast.LENGTH_SHORT).show();
                      }//edn inner run
  </code></pre>
  
  <p>All suggestions appreciated.
  Cheers
  Ciaran</p>
  
  <p>Resizing Image:
  When resizing the image: </p>
  
  <pre><code>Bitmap photoBitmap = Bitmap.createScaledBitmap(photo, 100, 100, false);
  </code></pre>
  
  <p>It works fine on the emulator with SD card activated, but crashes on a real device (a tablet 8inch)</p>