繁体   English   中英

android HD联系人照片大小的常量

[英]constant for android HD contact photo size

我知道android数据库会保留两种联系人照片,[[[照片最多可以以两种方式存储-默认“照片”是直接存储在数据行中的缩略图大小的图像,而“显示照片”如果存在,则是存储为文件的较大版本。 ]]]小的是96 * 96,大的是480 * 480,现在的问题是:

  1. 我仍然找不到大数据库,而小数据库是数据库中的“ data15”,请教我如何获得大数据库?
  2. 我需要将照片放置在启动器的第一个屏幕上,因此我需要至少800 * 480的照片,必须声明照片大小的常量。

PS:我尝试过:

intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);

但是当我打开数据库时,它变成了96 * 57 .....困惑。...有些帮助改变了它?

好人一声平安(那是中国好男孩,祝你好运)谢谢^ _ ^

我不太确定将照片存放两次意味着什么? 是的,那里的许多设备都会生成缩略图,但这更多是由于显示缩略图图像是常规用例。

您是否尝试获取用户ID并将其用于查询联系人数据表?

这可能是一个漫长的过程,但是,(伪代码)

Fetch contact id using the URI RawContacts.CONTENT_URI
Fetch Photo id using the URI Contacts.CONTENT_URI
Fetch Photo using the URI Data.CONTENT_URI, the projection you want here is Photo.PHOTO (this will give you a blob)

Google应该提供这些操作的易于阅读的示例:)

要获取更大的图像,可以使用以下代码(前提是您具有contactID):

public static InputStream getLargeContactPhoto(Long contactId, Context context) {
    Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
    Uri displayPhotoUri = Uri.withAppendedPath(contactUri, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
    try {
        AssetFileDescriptor fd = context.getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
        return fd.createInputStream();
    } catch (Exception e) {
        return null;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM