相关疑难解决方法(0)

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

背景

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

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

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

这个问题

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

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

android photo resolution image android-contacts

6
推荐指数
1
解决办法
8735
查看次数

Android从通话记录中获取联系人图片

People.CONTENT_URI通过简单的查询, 查询联系人图片非常容易

People.loadContactPhoto(activity, ContentUris.withAppendedId(People.CONTENT_URI, contactId)
Run Code Online (Sandbox Code Playgroud)

因为我知道联系人ID.现在我需要在访问呼叫日志后做同样的事情.附:

String[] strFields = {
                android.provider.CallLog.Calls.CACHED_NAME,
                android.provider.CallLog.Calls.NUMBER, 
                };

        String strUriCalls="content://call_log/calls"; 

            Uri UriCalls = Uri.parse(strUriCalls); 

            Cursor cursorLog = this.getContentResolver().query(UriCalls, strFields, null, null, null);
Run Code Online (Sandbox Code Playgroud)

我从通话记录列表中,但我不能找到加载照片所需要的接触ID连接这一点任何方式.该应用程序适用于api level 4+.

任何帮助表示赞赏.谢谢.

在下面的Cristian的指导下,对我有用的解决方案是:

 private long getContactIdFromNumber(String number) {
        String[] projection = new String[]{Contacts.Phones.PERSON_ID};
        Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL,Uri.encode(number));
        Cursor c = getContentResolver().query(contactUri, projection, null, null, null);

        if (c.moveToFirst()) {
            long contactId=c.getLong(c.getColumnIndex(Contacts.Phones.PERSON_ID));
            return contactId;
        }
        return -1;
    }
Run Code Online (Sandbox Code Playgroud)

android calllog contacts android-contacts

3
推荐指数
1
解决办法
8002
查看次数