微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.provider.ContactsContract.CommonDataKinds的实例源码

项目:Linphone4Android    文件LinphoneContact.java   
public void setPhoto(byte[] photo) {
    if (photo != null) {
        if (isAndroidContact()) {
            if (androidRawId != null) {
                changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                    .withValue(ContactsContract.Data.RAW_CONTACT_ID,androidRawId)
                    .withValue(ContactsContract.Data.MIMETYPE,CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
                    .withValue(CommonDataKinds.Photo.PHOTO,photo)
                    .withValue(ContactsContract.Data.IS_PRIMARY,1)
                    .withValue(ContactsContract.Data.IS_SUPER_PRIMARY,1)
                    .build());
            } else {
                changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
                    .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0)
                    .withValue(ContactsContract.Data.MIMETYPE,photo)
                    .build());
            }
        }
    }
}
项目:CSipSimple    文件ContactsUtils5.java   
@Override
public Intent getAddContactIntent(String displayName,String csipUri) {
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT,Contacts.CONTENT_URI);
    intent.setType(Contacts.CONTENT_ITEM_TYPE);

    if (!TextUtils.isEmpty(displayName)) {
        intent.putExtra(Insert.NAME,displayName);
    }

    if (!TextUtils.isEmpty(csipUri)) {
        ArrayList<ContentValues> data = new ArrayList<ContentValues>();
        ContentValues csipProto = new ContentValues();
        csipProto.put(Data.MIMETYPE,CommonDataKinds.Im.CONTENT_ITEM_TYPE);
        csipProto.put(CommonDataKinds.Im.PROTOCOL,CommonDataKinds.Im.PROTOCOL_CUSTOM);
        csipProto.put(CommonDataKinds.Im.CUSTOM_PROTOCOL,SipManager.PROTOCOL_CSIP);
        csipProto.put(CommonDataKinds.Im.DATA,SipUri.getCanonicalSipContact(csipUri,false));
        data.add(csipProto);

        intent.putParcelableArrayListExtra(Insert.DATA,data);
    }

    return intent;
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * Add an address to a list of database actions to be performed
 *
 * @param ops the list of database actions
 * @param address the item to be inserted
 */
private void insertAddress(ArrayList<ContentProviderOperation> ops,JSONObject address) {
    ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
            .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0)
            .withValue(ContactsContract.Data.MIMETYPE,CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE)
            .withValue(CommonDataKinds.StructuredPostal.TYPE,getAddresstype(getJsonString(address,"type")))
            .withValue(CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS,getJsonString(address,"formatted"))
            .withValue(CommonDataKinds.StructuredPostal.STREET,"streetAddress"))
            .withValue(CommonDataKinds.StructuredPostal.CITY,"locality"))
            .withValue(CommonDataKinds.StructuredPostal.REGION,"region"))
            .withValue(CommonDataKinds.StructuredPostal.POSTCODE,"postalCode"))
            .withValue(CommonDataKinds.StructuredPostal.COUNTRY,"country"))
            .withValue(CommonDataKinds.StructuredPostal.LABEL,"type"))
            .build());
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        return CommonDataKinds.Email.TYPE_CUSTOM;
    }
    return type;
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getorgType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Organization.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Organization.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Organization.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getAddresstype(String string) {
    int type = CommonDataKinds.StructuredPostal.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("work".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_OTHER;
        }
        else if ("home".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_HOME;
        }
        return CommonDataKinds.StructuredPostal.TYPE_CUSTOM;
    }
    return type;
}
项目:alerta-fraude    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getAddresstype(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.StructuredPostal.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getorgType(String string) {
    int type = CommonDataKinds.Organization.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());
        if ("work".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_OTHER;
        }
        else if ("custom".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_CUSTOM;
        }
    }
    return type;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        else if ("custom".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_CUSTOM;
        }
    }
    return type;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getorgType(String string) {
    int type = CommonDataKinds.Organization.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());
        if ("work".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_OTHER;
        }
        else if ("custom".equals(lowerType)) {
            return CommonDataKinds.Organization.TYPE_CUSTOM;
        }
    }
    return type;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getorgType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Organization.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Organization.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Organization.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getAddresstype(String string) {
    int type = CommonDataKinds.StructuredPostal.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("work".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_OTHER;
        }
        else if ("home".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_HOME;
        }
    }
    return type;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getAddresstype(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.StructuredPostal.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:smart-mirror-app    文件ContactAccessorSdk5.java   
/**
 * Create a ContactAddress JSONObject
 * @param cursor the current database row
 * @return a JSONObject representing a ContactAddress
 */
private JSONObject addressQuery(Cursor cursor) {
    JSONObject address = new JSONObject();
    try {
        address.put("id",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal._ID)));
        address.put("pref",false); // Android does not store pref attribute
        address.put("type",getAddresstype(cursor.getInt(cursor.getColumnIndex(CommonDataKinds.Organization.TYPE))));
        address.put("formatted",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS)));
        address.put("streetAddress",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.STREET)));
        address.put("locality",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.CITY)));
        address.put("region",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.REGION)));
        address.put("postalCode",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.POSTCODE)));
        address.put("country",cursor.getString(cursor.getColumnIndex(CommonDataKinds.StructuredPostal.COUNTRY)));
    } catch (JSONException e) {
        Log.e(LOG_TAG,e.getMessage(),e);
    }
    return address;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        else if ("custom".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_CUSTOM;
        }
    }
    return type;
}
项目:PhoneChat    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        else if ("custom".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_CUSTOM;
        }
    }
    return type;
}
项目:PhoneChat    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:PhoneChat    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getorgType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Organization.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Organization.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Organization.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:PhoneChat    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getAddresstype(String string) {
    int type = CommonDataKinds.StructuredPostal.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("work".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_OTHER;
        }
        else if ("home".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_HOME;
        }
    }
    return type;
}
项目:PhoneChat    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getAddresstype(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.StructuredPostal.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getAddresstype(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.StructuredPostal.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.StructuredPostal.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getorgType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Organization.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Organization.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Organization.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:Notepad    文件ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getAddresstype(String string) {
    int type = CommonDataKinds.StructuredPostal.TYPE_OTHER;
    if (string != null) {
        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("work".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_OTHER;
        }
        else if ("home".equals(lowerType)) {
            return CommonDataKinds.StructuredPostal.TYPE_HOME;
        }
    }
    return type;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。