获得从联系人信息的特定电话号码资料图片 [英] Get profile picture of specific phone number from contacts information
本文介绍了获得从联系人信息的特定电话号码资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发的消息发送/接收应用程序,我需要得到的电话号码资料图片。可能任何一个请帮我弄的具体数量的档案图片吗?
在此先感谢:)
解决方案
公共静态INT getContactIDFromNumber(字符串contactNumber,上下文的背景下)
{
contactNumber = Uri.en code(contactNumber);
。INT phoneContactID =新的随机()nextInt();
光标contactLookupCursor = context.getContentResolver().query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.en$c$c(contactNumber)),new的String [] {PhoneLookup.DISPLAY_NAME,PhoneLookup._ID},NULL,NULL,NULL);
而(contactLookupCursor.moveToNext()){
phoneContactID = contactLookupCursor.getInt(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup._ID));
}
contactLookupCursor.close(); 返回phoneContactID;
}
以上方法返回的特定的电话号码的ContactID并参阅这篇链接从得到的ContactID资料图片。
I am developing message send/receive application, and i need to get profile picture of phone number. Could any one please help me to get the profile picture of specific number?
Thanks in advance :)
解决方案
public static int getContactIDFromNumber(String contactNumber,Context context)
{
contactNumber = Uri.encode(contactNumber);
int phoneContactID = new Random().nextInt();
Cursor contactLookupCursor = context.getContentResolver().query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.encode(contactNumber)),new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup._ID}, null, null, null);
while(contactLookupCursor.moveToNext()){
phoneContactID = contactLookupCursor.getInt(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup._ID));
}
contactLookupCursor.close();
return phoneContactID;
}
The above method returns contactId of specific phone number and refer this LINK to get profile picture from contactID.
这篇关于获得从联系人信息的特定电话号码资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文