i got a problem
i use
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
to select picture from gallery and load back to my app
it works ok in the emulator
but when i put my app on real phone(HTC HERO/HTC MAGIC)
it sometimes crash when it loaded back (not always)
sometimes i capture photo first, and select it
is it because the photo size is too large or something?
does anyone know why?
//===following are part of my code ====///
private void getGalleryImage()
{
//...
selectNewPicture = false;
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,Intent data)
{
if (resultCode == RESULT_OK)
{
uriAvator = data.getData();
ContentResolver cr = this.getContentResolver();
try
{
bmpAvator = Bitmap.createBitmap(BitmapFactory.decodeStream(cr.openInputStream(uriAvator)));
//Do Cutting
int dX = bmpAvator.getWidth();
int dY = bmpAvator.getHeight();
int dMin = Math.min(dX, dY);
if(dX > dY)
bmpAvator = Bitmap.createBitmap(bmpAvator, (dX-dMin)>>1, 0, dMin, dMin);
else if(dX < dY)
bmpAvator = Bitmap.createBitmap(bmpAvator, 0, (dY-dMin)>>1, dMin, dMin);
//Do Scaling
bmpAvator = Bitmap.createScaledBitmap(bmpAvator, 100, 100, true);
//Compress into jpeg
myAvator.setImageBitmap(bmpAvator);
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
super.onActivityResult(requestCode, resultCode, data);
}



