title: Picking images from gallery (SD Card) on my app… ¿How to allow only max 500kb photos?
body: <p><strong>WHAT I HAVE DONE NOW:</strong> 
  i am picking images on my app with android, and showing them on a ImageView of my layout, and sometimes i got an exception <code>java.lang.OutOfMemoryError: bitmap size exceeds VM budget</code>. This happens when the photos are higher than 500kb.</p>
  
  <p><strong>WHAT I NEED TO DO (AND I DONT KNOW HOW TO DO IT):</strong>
  then, what i want to do is to allow the user only to select photos of maximum 500kb. And if the user selects a photo Higher than 500kb, then, my app should show a toast telling the user that only can select photos of max 500kb.... ¿how to do it?</p>
  
  <p>this is my code: </p>
  
  <pre><code>changeImageButton.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  Intent i = new Intent(Intent.ACTION_PICK,
                          android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                  startActivityForResult(i, ACTIVITY_SELECT_IMAGE);
              }
          }); 
  
  
  
  protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
          super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 
  
          switch(requestCode) {
          case 1:
          {
              setResult(1);
              finish();    
          }
          case ACTIVITY_SELECT_IMAGE:
              if(resultCode == RESULT_OK){  
                  Uri selectedImage = imageReturnedIntent.getData();
                  String[] filePathColumn = {MediaStore.Images.Media.DATA};
  
                  Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                  cursor.moveToFirst();
  
                  int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                  String filePath = cursor.getString(columnIndex);
                  cursor.close();
  
                  selectedPhoto = BitmapFactory.decodeFile(filePath);
                  //profileImage.setImageBitmap(selectedPhoto);
                  profileImage.setImageBitmap(Bitmap.createScaledBitmap(selectedPhoto, 80, 80, false));
              }
          }
      }
  </code></pre>
  
  <p>profileImage is a ImageView of my layout. and i use scaled butmap to resice the image to 80x80</p>
  
  <p>please give me some help to do that, im searching on google and i can't find nothing</p>