本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Im类的典型用法代码示例。如果您正苦于以下问题:Java Im类的具体用法?Java Im怎么用?Java Im使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Im类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了Im类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIMAddressesMap
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
private SparseArray<List<IMAddress>> getIMAddressesMap() {
SparseArray<List<IMAddress>> idImAddressMap = new SparseArray<>();
Cursor cur = getCursorFromContentType(new String[]{ID_KEY, MAIN_DATA_KEY, Im.PROTOCOL, Im.CUSTOM_PROTOCOL}, Im.CONTENT_ITEM_TYPE);
if (cur != null) {
while (cur.moveToNext()) {
int id = cur.getInt(cur.getColumnIndex(ID_KEY));
String data = cur.getString(cur.getColumnIndex(MAIN_DATA_KEY));
int labelId = cur.getInt(cur.getColumnIndex(Im.PROTOCOL));
String customLabel = cur.getString(cur.getColumnIndex(Im.CUSTOM_PROTOCOL));
IMAddress current;
if (customLabel == null)
current = new IMAddress(mCtx, data, labelId);
else
current = new IMAddress(data, customLabel);
List<IMAddress> currentWebsiteList = idImAddressMap.get(id);
if (currentWebsiteList == null) {
currentWebsiteList = new ArrayList<>();
currentWebsiteList.add(current);
idImAddressMap.put(id, currentWebsiteList);
} else currentWebsiteList.add(current);
}
cur.close();
}
return idImAddressMap;
}
示例2: initColumnNameConstantsMap
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
private void initColumnNameConstantsMap() {
if (mColumnNameConstantsMap != null) {
return;
}
mColumnNameConstantsMap = new HashMap<String, String>();
mColumnNameConstantsMap.put("name", StructuredName.DISPLAY_NAME);
mColumnNameConstantsMap.put("givenname", StructuredName.GIVEN_NAME);
mColumnNameConstantsMap.put("familyname", StructuredName.FAMILY_NAME);
mColumnNameConstantsMap.put("honorificprefix", StructuredName.PREFIX);
mColumnNameConstantsMap.put("honorificsuffix", StructuredName.SUFFIX);
mColumnNameConstantsMap.put("additionalname", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("nickname", Nickname.NAME);
mColumnNameConstantsMap.put("adr", StructuredPostal.STREET);
mColumnNameConstantsMap.put("email", Email.ADDRESS);
mColumnNameConstantsMap.put("url", Website.URL);
mColumnNameConstantsMap.put("category", GroupMembership.GROUP_ROW_ID);
mColumnNameConstantsMap.put("tel", Phone.NUMBER);
mColumnNameConstantsMap.put("org", Organization.COMPANY);
mColumnNameConstantsMap.put("jobTitle", Organization.TITLE);
mColumnNameConstantsMap.put("note", Note.NOTE);
mColumnNameConstantsMap.put("impp", Im.DATA);
mColumnNameConstantsMap.put("sex", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("genderidentity", CUSTOM_DATA_COLUMN);
mColumnNameConstantsMap.put("key", CUSTOM_DATA_COLUMN);
}
示例3: initMimeTypeConstantsMap
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
private void initMimeTypeConstantsMap() {
if (mMimeTypeConstantsMap != null) {
return;
}
mMimeTypeConstantsMap = new HashMap<String, String>();
mMimeTypeConstantsMap.put("name", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("givenname", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("familyname", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificprefix", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("honorificsuffix", StructuredName.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("additionalname", MIMETYPE_ADDITIONAL_NAME);
mMimeTypeConstantsMap.put("nickname", Nickname.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("email", Email.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("url", Website.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("category", GroupMembership.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("tel", Phone.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("org", Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("jobTitle", Organization.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("note", Note.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("impp", Im.CONTENT_ITEM_TYPE);
mMimeTypeConstantsMap.put("sex", MIMETYPE_SEX);
mMimeTypeConstantsMap.put("genderidentity", MIMETYPE_GENDER_IDENTITY);
mMimeTypeConstantsMap.put("key", MIMETYPE_KEY);
}
示例4: addIm
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
public ContactOperations addIm(String data, int type, String label,
boolean isPrimary, boolean isSuperPrimary, int imProtocolType,
String customProtocolName) {
mValues.clear();
if (!TextUtils.isEmpty(data)) {
mValues.put(Im.DATA, data);
mValues.put(Im.TYPE, type);
mValues.put(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE);
if (!TextUtils.isEmpty(label)) {
mValues.put(Im.LABEL, label);
}
if (isSuperPrimary) {
mValues.put(Email.IS_SUPER_PRIMARY, 1);
}
if (isPrimary) {
mValues.put(Email.IS_PRIMARY, 1);
}
mValues.put(Im.PROTOCOL, imProtocolType);
if (!TextUtils.isEmpty(customProtocolName)) {
mValues.put(Im.CUSTOM_PROTOCOL, customProtocolName);
}
addInsertOp();
}
return this;
}
示例5: getAndroidImProtocolType
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
public static int getAndroidImProtocolType(ImProtocolType type) {
switch (type) {
case PROTOCOL_AIM:
return Im.PROTOCOL_AIM;
case PROTOCOL_CUSTOM:
return Im.PROTOCOL_CUSTOM;
case PROTOCOL_GOOGLE_TALK:
return Im.PROTOCOL_GOOGLE_TALK;
case PROTOCOL_ICQ:
return Im.PROTOCOL_ICQ;
case PROTOCOL_JABBER:
return Im.PROTOCOL_JABBER;
case PROTOCOL_MSN:
return Im.PROTOCOL_MSN;
case PROTOCOL_NETMEETING:
return Im.PROTOCOL_NETMEETING;
case PROTOCOL_QQ:
return Im.PROTOCOL_QQ;
case PROTOCOL_SKYPE:
return Im.PROTOCOL_SKYPE;
case PROTOCOL_YAHOO:
return Im.PROTOCOL_YAHOO;
default:
return Im.PROTOCOL_CUSTOM;
}
}
示例6: getImProtocolType
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
public static ImProtocolType getImProtocolType(int androidType) {
switch (androidType) {
case Im.PROTOCOL_AIM:
return ImProtocolType.PROTOCOL_AIM;
case Im.PROTOCOL_CUSTOM:
return ImProtocolType.PROTOCOL_CUSTOM;
case Im.PROTOCOL_GOOGLE_TALK:
return ImProtocolType.PROTOCOL_GOOGLE_TALK;
case Im.PROTOCOL_ICQ:
return ImProtocolType.PROTOCOL_ICQ;
case Im.PROTOCOL_JABBER:
return ImProtocolType.PROTOCOL_JABBER;
case Im.PROTOCOL_MSN:
return ImProtocolType.PROTOCOL_MSN;
case Im.PROTOCOL_NETMEETING:
return ImProtocolType.PROTOCOL_NETMEETING;
case Im.PROTOCOL_QQ:
return ImProtocolType.PROTOCOL_QQ;
case Im.PROTOCOL_SKYPE:
return ImProtocolType.PROTOCOL_SKYPE;
case Im.PROTOCOL_YAHOO:
return ImProtocolType.PROTOCOL_YAHOO;
default:
return ImProtocolType.PROTOCOL_CUSTOM;
}
}
示例7: Assets
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
public Assets(Context context, long contactId) {
this.context = context;
cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String[]{Data._ID,
Data.RAW_CONTACT_ID, Data.MIMETYPE, Data.IS_PRIMARY,
Data.IS_SUPER_PRIMARY, Data.DATA_VERSION, Data.DATA1,
Data.DATA2, Data.DATA3, Data.DATA4, Data.DATA5, Data.DATA6,
Data.DATA7, Data.DATA8, Data.DATA9, Data.DATA10, Data.DATA11,
Data.DATA12, Data.DATA13, Data.DATA14, Data.DATA15, Data.SYNC1,
Data.SYNC2, Data.SYNC3, Data.SYNC4, },
Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + " IN ( ?, ?, ?, ?, ?, ? )",
new String[]{
String.valueOf(contactId),
Nickname.CONTENT_ITEM_TYPE,
Im.CONTENT_ITEM_TYPE,
Photo.CONTENT_ITEM_TYPE,
},
null);
//cursor.moveToFirst();
columnNames = cursor.getColumnNames();
}
示例8: addIM
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
@Override
public boolean addIM(ContactStruct contact, Cursor ims, Context ctx, boolean removeMatches) {
boolean ret = false;
String data = ims.getString(ims.getColumnIndexOrThrow(Im.DATA));
String protocol = ims.getString(ims.getColumnIndexOrThrow(Im.PROTOCOL));
String label = ims.getString(ims.getColumnIndexOrThrow(Im.LABEL));
int type = ims.getInt(ims.getColumnIndexOrThrow(Im.TYPE));
boolean primary = (ims.getInt(ims.getColumnIndexOrThrow(Im.IS_PRIMARY)) != 0);
int prot = 0;
if (!TextUtils.isEmpty(protocol) && !TextUtils.isEmpty(data)) {
String value = data;
prot = Integer.valueOf(protocol);
if (prot == Im.PROTOCOL_CUSTOM) {
return false;
} else {
label = lookupProviderNameFromId(prot).toLowerCase(Locale.US);
}
if (!TextUtils.isEmpty(label) && isImNew(contact, value, label, removeMatches)) {
contact.addContactmethod(Contacts.KIND_IM, type, value, label, primary);
ret = true;
}
}
return ret;
}
示例9: lookupProviderNameFromId
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
@Override
public String lookupProviderNameFromId(int protocol) {
switch (protocol) {
case Im.PROTOCOL_GOOGLE_TALK:
return GTALK;
case Im.PROTOCOL_AIM:
return AIM;
case Im.PROTOCOL_MSN:
return MSN;
case Im.PROTOCOL_YAHOO:
return YAHOO;
case Im.PROTOCOL_ICQ:
return ICQ;
case Im.PROTOCOL_JABBER:
return JABBER;
case Im.PROTOCOL_SKYPE:
return SKYPE;
case Im.PROTOCOL_QQ:
return QQ;
case Im.PROTOCOL_NETMEETING:
return NETMEETING;
}
return null;
}
示例10: lookupProviderIdFromName
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
@Override
public int lookupProviderIdFromName(String name) {
if (GTALK.equalsIgnoreCase(name))
return Im.PROTOCOL_GOOGLE_TALK;
else if (AIM.equalsIgnoreCase(name))
return Im.PROTOCOL_AIM;
else if (MSN.equalsIgnoreCase(name))
return Im.PROTOCOL_MSN;
else if (YAHOO.equalsIgnoreCase(name))
return Im.PROTOCOL_YAHOO;
else if (ICQ.equalsIgnoreCase(name))
return Im.PROTOCOL_ICQ;
else if (JABBER.equalsIgnoreCase(name))
return Im.PROTOCOL_JABBER;
else if (SKYPE.equalsIgnoreCase(name))
return Im.PROTOCOL_SKYPE;
else if (QQ.equalsIgnoreCase(name))
return Im.PROTOCOL_QQ;
else if (NETMEETING.equalsIgnoreCase(name))
return Im.PROTOCOL_NETMEETING;
else
return Im.PROTOCOL_CUSTOM;
}
示例11: byProtocolId
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
/**
* Retrieve the Protocol instance for a given raw database value.
* @param id The raw database value.
* @return The corresponding Protocol instance, or null.
*/
public static Protocol byProtocolId(int id) {
switch(id) {
case Im.PROTOCOL_CUSTOM: return CUSTOM;
case Im.PROTOCOL_AIM: return AIM;
case Im.PROTOCOL_MSN: return MSN;
case Im.PROTOCOL_YAHOO: return YAHOO;
case Im.PROTOCOL_SKYPE: return SKYPE;
case Im.PROTOCOL_QQ: return QQ;
case Im.PROTOCOL_GOOGLE_TALK: return GOOGLE_TALK;
case Im.PROTOCOL_ICQ: return ICQ;
case Im.PROTOCOL_JABBER: return JABBER;
case Im.PROTOCOL_NETMEETING: return NETMEETING;
}
return null;
}
示例12: insertIm
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
/**
* Add an im to a list of database actions to be performed
*
* @param ops the list of database actions
* @param im the item to be inserted
*/
private void insertIm(ArrayList<ContentProviderOperation> ops, JSONObject im) {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE)
.withValue(CommonDataKinds.Im.DATA, getJsonString(im, "value"))
.withValue(CommonDataKinds.Im.PROTOCOL, getImType(getJsonString(im, "type")))
.withValue(CommonDataKinds.Im.CUSTOM_PROTOCOL, getJsonString(im, "type"))
.build());
}
示例13: getImType
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
/**
* Converts a string from the W3C Contact API to it's Android int value.
* @param string
* @return Android int value
*/
private int getImType(String string) {
int type = CommonDataKinds.Im.PROTOCOL_CUSTOM;
if (string != null) {
String lowerType = string.toLowerCase(Locale.getDefault());
if ("aim".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_AIM;
}
else if ("google talk".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK;
}
else if ("icq".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_ICQ;
}
else if ("jabber".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_JABBER;
}
else if ("msn".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_MSN;
}
else if ("netmeeting".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_NETMEETING;
}
else if ("qq".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_QQ;
}
else if ("skype".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_SKYPE;
}
else if ("yahoo".equals(lowerType)) {
return CommonDataKinds.Im.PROTOCOL_YAHOO;
}
}
return type;
}
示例14: getProtocolName
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
private String getProtocolName(String protocolId, String customProtocol) {
if (protocolId == null) {
throw new InvalidCursorTypeException();
}
switch (Integer.valueOf(protocolId)) {
case Im.PROTOCOL_AIM:
return "AIM";
case Im.PROTOCOL_MSN:
return "MSN";
case Im.PROTOCOL_YAHOO:
return "Yahoo";
case Im.PROTOCOL_SKYPE:
return "Skype";
case Im.PROTOCOL_QQ:
return "QQ";
case Im.PROTOCOL_GOOGLE_TALK:
return "Google Talk";
case Im.PROTOCOL_ICQ:
return "ICQ";
case Im.PROTOCOL_JABBER:
return "Jabber";
case Im.PROTOCOL_NETMEETING:
return "NetMeeting";
case Im.PROTOCOL_CUSTOM:
return customProtocol;
default:
return "Other";
}
}
示例15: getImsValues
import android.provider.ContactsContract.CommonDataKinds.Im; //导入依赖的package包/类
private void getImsValues(final JSONArray ims, List<ContentValues> newContactValues) throws JSONException {
if (ims == null) {
return;
}
for (int i = 0; i < ims.length(); i++) {
JSONObject im = ims.getJSONObject(i);
JSONArray imTypes = im.optJSONArray("type");
if (imTypes != null && imTypes.length() > 0) {
for (int j = 0; j < imTypes.length(); j++) {
// Translate the IM type string to an integer constant
// provided by the ContactsContract API
final String type = imTypes.getString(j);
final int typeConstant = getImType(type);
newContactValues.add(createContentValues(Im.CONTENT_ITEM_TYPE,
im.optString("value"),
typeConstant, type,
im.optBoolean("pref")));
}
} else {
newContactValues.add(createContentValues(Im.CONTENT_ITEM_TYPE,
im.optString("value"),
-1, null, im.optBoolean("pref")));
}
}
}