获取联系人头像

 public byte[] getPhoto(String people_id) {
  String photo_id = null;
  String selection1 = ContactsContract.Contacts._ID + " = " + people_id;
  Cursor cur1 = getContentResolver().query(
    ContactsContract.Contacts.CONTENT_URI, null, selection1, null,
    null);
  if (cur1.getCount() > 0) {
   cur1.moveToFirst();
   photo_id = cur1.getString(cur1
     .getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
   //System.out.println("photo_id:" + photo_id);
  }
  String[] projection = new String[] {
  ContactsContract.Data.DATA15
  };
  String selection = ContactsContract.Data._ID + " = " + photo_id;
  Cursor cur = getContentResolver().query(
    ContactsContract.Data.CONTENT_URI, projection, selection, null,
    null);
  cur.moveToFirst();
  byte[] contactIcon = cur.getBlob(0);
  System.out.println("conTactIcon:" + contactIcon);
  if (contactIcon == null) {
   return null;
  } else {
   return contactIcon;
  }
}



 

阅读更多
文章标签: string null byte
个人分类: android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭