Contact photos are 96x96 on my Nexus S. I really don't want to 'bake' that knowledge into my code - is there a constant somewhere that declares this? I've looked, but can't seem to find one.
In android 2.3+ there is a ThumbnailUtils class that has
/**
* Constant used to indicate the dimension of micro thumbnail.
* @hide Only used by media framework and media provider internally.
*/
public static final int TARGET_SIZE_MICRO_THUMBNAIL = 96;
but that @hide hides it from us.
Looking at the Contacts app source code, file AttachImage.java I found another interesting thing:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
// omitted
if (requestCode == REQUEST_PICK_CONTACT) {
// 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);
That TODO and those intent.putExtra say a lot, even if there is a thumbnail size constant, it isn't used in the contact app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With