if (resultCode != RESULT_OK) {
finish();
return;
}
if (requestCode == REQUEST_PICK_CONTACT) {
mContactUri = result.getData();
// A contact was picked. Launch the cropper to get face detection, the right size, etc.
// TODO: get these values from constants somewhere
Intent myIntent = getIntent();
Intent intent = new Intent("com.android.camera.action.CROP", myIntent.getData());
if (myIntent.getStringExtra("mimeType") != null) {
intent.setDataAndType(myIntent.getData(), myIntent.getStringExtra("mimeType"));
}
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);
intent.putExtra("return-data", true);
startActivityForResult(intent, REQUEST_CROP_PHOTO);
} else if (requestCode == REQUEST_CROP_PHOTO) {
final Bundle extras = result.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
if (photo != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);
Contacts.People.setPhotoData(getContentResolver(), mContactUri,
stream.toByteArray());
}
}
finish();
}