如何查找联系人图片支持的最大图像大小?

and*_*per 6 android photo resolution image android-contacts

背景

从jelly bean(4.1)开始,android现在支持720x720的联系人图像.

之前,从ICS(4.0)开始,android支持256x256的联系人图像.

在此之前,联系人照片只有缩略图的大小 - 96x96

这个问题

API中是否有任何函数返回联系人图像的最大大小?

我也希望制造商不会改变最大图像尺寸,即使他们这样做了,我们也有这样的功能,它会给我们带来正确的尺寸.

and*_*per 5

根据此链接,获取最大大小的正确方法是:

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static int getMaxContactPhotoSize(final Context context) {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        // Note that this URI is safe to call on the UI thread.
        final Uri uri = ContactsContract.DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI;
        final String[] projection = new String[] { ContactsContract.DisplayPhoto.DISPLAY_MAX_DIM };
        final Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
        try {
            c.moveToFirst();
            return c.getInt(0);
        } finally {
            c.close();
        }
    }
    // fallback: 96x96 is the max contact photo size for pre-ICS versions
    return 96;
}
Run Code Online (Sandbox Code Playgroud)