i got a problem
i intend to use
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
to select picture from gallery in google phone, and load the selected
photo back into my application
it works ok in the emulator
but when i punt it on real google phone (HTC hero/ HTC magic)
if i capture a photo in the gallery, and select the photo,
it sometimes crash (not always)
is it because the photo is too large or something?
are there any solution? thanks!
//--------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);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---