本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Email类的典型用法代码示例。如果您正苦于以下问题:Java Email类的具体用法?Java Email怎么用?Java Email使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Email类属于android.provider.ContactsContract.CommonDataKinds包,在下文中一共展示了Email类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEvent
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
public ContactOperations addEvent(String event, int type, String label,
boolean isPrimary, boolean isSuperPrimary) {
mValues.clear();
if (!TextUtils.isEmpty(event)) {
mValues.put(Event.START_DATE, event);
mValues.put(Event.TYPE, type);
mValues.put(Event.MIMETYPE, Event.CONTENT_ITEM_TYPE);
if (!TextUtils.isEmpty(label)) {
mValues.put(Event.LABEL, label);
}
if (isSuperPrimary) {
mValues.put(Email.IS_SUPER_PRIMARY, 1);
}
if (isPrimary) {
mValues.put(Email.IS_PRIMARY, 1);
}
addInsertOp();
}
return this;
}
示例2: onClick
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Override
public void onClick(View v) {
// If contact has been assigned, extras should no longer be null, but do a null check
// anyway just in case assignContactFromPhone or Email was called with a null bundle or
// wasn't assigned previously.
final Bundle extras = (this.extras == null) ? new Bundle() : this.extras;
if (contactUri != null) {
QuickContact.showQuickContact(getContext(), ContactBadge.this, contactUri,
QuickContact.MODE_LARGE, null);
} else if (contactEmail != null) {
extras.putString(EXTRA_URI_CONTENT, contactEmail);
queryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(contactEmail)),
EMAIL_LOOKUP_PROJECTION, null, null, null);
}
}
示例3: fillContactDataFromLookupKey
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
private void fillContactDataFromLookupKey(Uri lookupKeyUri, List<Recipient> recipients,
Map<String, Recipient> recipientMap) {
// We could use the contact id from the URI directly, but getting it from the lookup key is safer
Uri contactContentUri = Contacts.lookupContact(contentResolver, lookupKeyUri);
if (contactContentUri == null) {
return;
}
String contactIdStr = getContactIdFromContactUri(contactContentUri);
Cursor cursor = contentResolver.query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
PROJECTION, ContactsContract.CommonDataKinds.Email.CONTACT_ID + "=?",
new String[] { contactIdStr }, null);
if (cursor == null) {
return;
}
fillContactDataFromCursor(cursor, recipients, recipientMap);
}
示例4: fillContactDataFromNameAndEmail
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
private boolean fillContactDataFromNameAndEmail(String query, List<Recipient> recipients,
Map<String, Recipient> recipientMap) {
query = "%" + query + "%";
Uri queryUri = Email.CONTENT_URI;
String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
" OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
String[] selectionArgs = { query, query };
Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);
if (cursor == null) {
return false;
}
fillContactDataFromCursor(cursor, recipients, recipientMap);
return true;
}
示例5: onClick
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Override
public void onClick(View v) {
// If contact has been assigned, mExtras should no longer be null, but do a null check
// anyway just in case assignContactFromPhone or Email was called with a null bundle or
// wasn't assigned previously.
final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
if (mContactUri != null) {
QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
} else if (mContactEmail != null && mQueryHandler != null) {
extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
} else if (mContactPhone != null && mQueryHandler != null) {
extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
} else {
// If a contact hasn't been assigned, don't react to click.
return;
}
}
示例6: getContactType
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
/**
* 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;
}
示例7: fillContactDataFromLookupKey
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
private void fillContactDataFromLookupKey(Uri lookupKeyUri, List<Recipient> recipients,
Map<String, Recipient> recipientMap) {
// We could use the contact id from the URI directly, but getting it from the lookup key is safer
Uri contactContentUri = Contacts.lookupContact(getContext().getContentResolver(), lookupKeyUri);
if (contactContentUri == null) {
return;
}
String contactIdStr = getContactIdFromContactUri(contactContentUri);
Cursor cursor = getContext().getContentResolver().query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
PROJECTION, ContactsContract.CommonDataKinds.Email.CONTACT_ID + "=?",
new String[] { contactIdStr }, null);
if (cursor == null) {
return;
}
fillContactDataFromCursor(cursor, recipients, recipientMap);
}
示例8: fillContactDataFromQuery
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
private void fillContactDataFromQuery(String query, List<Recipient> recipients,
Map<String, Recipient> recipientMap) {
ContentResolver contentResolver = getContext().getContentResolver();
query = "%" + query + "%";
Uri queryUri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
" OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
String[] selectionArgs = { query, query };
Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);
if (cursor == null) {
return;
}
fillContactDataFromCursor(cursor, recipients, recipientMap);
if (observerContact != null) {
observerContact = new ForceLoadContentObserver();
contentResolver.registerContentObserver(queryUri, false, observerContact);
}
}
示例9: getAllContactsEmailAddressesInfo
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Override
public AddressBookEmailBuilder getAllContactsEmailAddressesInfo(Activity activity) {
String[] PROJECTION = new String[] { Contacts._ID, Contacts.DISPLAY_NAME, Email.DATA };
Cursor c = activity.managedQuery(Email.CONTENT_URI, PROJECTION, null, null, null);
// We give a list of emails: [email protected],[email protected],[email protected]
// We get back only a list of emails of users that exist on the system ([email protected])
// Iterate over all those returned users, on each iteration, remove from our hashmap.
// Can now use the left over hashmap, which is still in correct order to display invites.
AddressBookEmailBuilder bld = new AddressBookEmailBuilder();
if (c.moveToFirst()) {
bld.addContact(c.getString(1), c.getString(2));
while (c.moveToNext()) {
bld.addContact(c.getString(1), c.getString(2));
}
}
c.close();
return bld;
}
示例10: p
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
private final Cursor p()
{
localhqr = new hqr(this.r);
Uri localUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(this.s));
Cursor localCursor = this.l.getContentResolver().query(localUri, v, null, null, null);
if (localCursor == null) {
return localhqr;
}
try
{
while (localCursor.moveToNext()) {
if (!TextUtils.isEmpty(localCursor.getString(2))) {
localhqr.a(b(localCursor));
}
}
return localhqr;
}
finally
{
localCursor.close();
}
}
示例11: testAppendNameProperties_email
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Test
public void testAppendNameProperties_email() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
cv.put(Email.IS_PRIMARY, 0);
cv.put(Email.DATA1, "[email protected]");
group.add(cv);
final String card = builder.appendEmails(group).toString();
assertEquals(EMAIL_CARD_1, card);
}
示例12: testAppendNameProperties_htcOneDifferentOutput
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Test
public void testAppendNameProperties_htcOneDifferentOutput() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
cv.put(Email.DATA, "[email protected]");
cv.put(Email.TYPE, 3);
cv.put(Email.LABEL, "");
cv.put(Email.IS_PRIMARY, 1);
group.add(cv);
final String card = builder.appendEmails(group).toString();
assertEquals(EMAIL_CARD_2, card);
}
示例13: testAppendNameProperties_phone
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Test
public void testAppendNameProperties_phone() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
cv.put(Email.IS_PRIMARY, 0);
cv.put(Email.DATA1, "(123) 123-4567");
group.add(cv);
final String card = builder.appendPhones(group, null).toString();
assertEquals(PHONE_CARD, card);
}
示例14: testAppendNameProperties_name
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
@Test
public void testAppendNameProperties_name() {
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
VCardConfig.DEFAULT_EXPORT_CHARSET);
final ContentValues cv = new ContentValues();
final List<ContentValues> group = new ArrayList<>();
cv.put(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
cv.put(Email.DATA1, "Spruce Grouse");
cv.put(Email.DATA2, "Spruce");
cv.put(Email.DATA3, "Grouse");
group.add(cv);
final String card = builder.appendNameProperties(group).toString();
assertEquals(NAME_CARD, card);
}
示例15: getEamilByContactId
import android.provider.ContactsContract.CommonDataKinds.Email; //导入依赖的package包/类
/**
* @param contentResolver
* @param contactId
*/
private static String getEamilByContactId(ContentResolver contentResolver,
String contactId) {
Cursor emailCursor = null;
String email = null;
try {
emailCursor = contentResolver
.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[] { ContactsContract.CommonDataKinds.Email.DATA },
ContactsContract.CommonDataKinds.Email.CONTACT_ID
+ "=?", new String[] { contactId }, null);
if (emailCursor.moveToFirst()) {
email = emailCursor
.getString(emailCursor
.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (emailCursor != null) {
emailCursor.close();
}
}
return email;
}