开发者

Declared constant for Android contact photo size?

开发者 https://www.devze.com 2023-03-26 11:02 出处:网络
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 decla开发者_StackOverflow中文版res this? I\'ve looked, but can

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 decla开发者_StackOverflow中文版res 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消