示例#1
0
    /*       private Contact getContactInfoForSelf() {
                Contact entry = new Contact(true);
                entry.mContactMethodType = CONTACT_METHOD_TYPE_SELF;

                if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
                    log("getContactInfoForSelf");
                }
                Cursor cursor = mContext.getContentResolver().query(
                        Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);
                if (cursor == null) {
                    Log.w(TAG, "getContactInfoForSelf() returned NULL cursor!"
                            + " contact uri used " + Profile.CONTENT_URI);
                    return entry;
                }

                try {
                    if (cursor.moveToFirst()) {
                        fillSelfContact(entry, cursor);
                    }
                } finally {
                    cursor.close();
                }
                return entry;
            }
    */
    private void fillPhoneTypeContact(final Contact contact, final Cursor cursor) {
      synchronized (contact) {
        contact.mContactMethodType = CONTACT_METHOD_TYPE_PHONE;
        contact.mContactMethodId = cursor.getLong(PHONE_ID_COLUMN);
        contact.mLabel = cursor.getString(PHONE_LABEL_COLUMN);
        contact.mName = cursor.getString(CONTACT_NAME_COLUMN);
        contact.mPersonId = cursor.getLong(CONTACT_ID_COLUMN);
        contact.mPresenceResId = getPresenceIconResourceId(cursor.getInt(CONTACT_PRESENCE_COLUMN));
        contact.mPresenceText = cursor.getString(CONTACT_STATUS_COLUMN);
        contact.mNumberE164 = cursor.getString(PHONE_NORMALIZED_NUMBER);
        contact.mSendToVoicemail = cursor.getInt(SEND_TO_VOICEMAIL) == 1;
        if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
          log(
              "fillPhoneTypeContact: name="
                  + contact.mName
                  + ", number="
                  + contact.mNumber
                  + ", presence="
                  + contact.mPresenceResId
                  + " SendToVoicemail: "
                  + contact.mSendToVoicemail);
        }
      }
      byte[] data = loadAvatarData(contact);

      synchronized (contact) {
        contact.mAvatarData = data;
      }
    }