Java Code Examples for android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS

The following examples show how to use android.provider.ContactsContract.CommonDataKinds.Email#ADDRESS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Get the DATA_PROJECTION for ContactPicker and PhoneNumberPicker.
 */
public static String[] getDataProjection() {
  String[] dataProjection = {
    Data.MIMETYPE,
    Email.ADDRESS,
    Email.TYPE,
    Phone.NUMBER,
    Phone.TYPE,
  };
  return dataProjection;
}
 
Example 2
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Get the NEW_PROJECTION for EmailAddressAdapter.
 */
public static String[] getEmailAdapterProjection() {
  String[] emailAdapterProjection = {
    Data._ID,
    Data.DISPLAY_NAME,
    Email.ADDRESS,
    Data.MIMETYPE,
  };
  return emailAdapterProjection;
}
 
Example 3
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Get Email.ADDRESS for EmailAddressAdapter.
 */
public static String getEmailAddress() {
  return Email.ADDRESS;
}
 
Example 4
Source File: ContactDetailFragment.java    From Contacts with MIT License 4 votes vote down vote up
@Override
protected Contact doInBackground(Cursor... params)
{
	mContact = new Contact();
	mContact.setLookupKey(mLookupKey);

	Cursor cursor = params[0];

	if (cursor != null && !cursor.isClosed())
	{
		while (cursor.moveToNext())
		{
			long id = cursor.getLong(0);
			String name = cursor.getString(1);
			String firstName = cursor.getString(2);
			String lastName = cursor.getString(3);
			String photo = cursor.getString(4);
			String photoThumb = cursor.getString(5);
			int starred = cursor.getInt(6);

			mContact.setId(id);

			if (name != null)
				mContact.setName(name);

			if (firstName != null)
				mContact.setFirstName(firstName);

			if (lastName != null)
				mContact.setLastName(lastName);

			if (photo != null)
				mContact.setPhoto(photo);

			if (photoThumb != null)
				mContact.setPhotoThumb(photoThumb);

			mContact.setStarred(starred == 1);
		}

		cursor.close();
	}

	String[] projection = { Phone.TYPE, Phone.NORMALIZED_NUMBER, Phone.LABEL, Phone.NUMBER };
	String selection = Phone.LOOKUP_KEY + " = ?";
	String[] parameters = new String[] { mLookupKey };
	Cursor phones = getActivity().getContentResolver().query(Phone.CONTENT_URI, projection, selection, parameters, null);

	while (phones.moveToNext())
	{
		if (phones.getString(1) != null)
			mContact.addPhoneNumber(phones.getInt(0), phones.getString(1), phones.getString(2));
		else
			mContact.addPhoneNumber(phones.getInt(0), phones.getString(3), phones.getString(2));
	}

	phones.close();

	// Same process for the names
	projection = new String[] { Email.TYPE, Email.ADDRESS };
	selection = Email.LOOKUP_KEY + " = ?";
	parameters = new String[] { mLookupKey };

	Cursor emails = getActivity().getContentResolver().query(Email.CONTENT_URI, projection, selection, parameters, null);

	while (emails.moveToNext())
	{
		mContact.addEmailAddress(emails.getInt(0), emails.getString(1));
	}

	return mContact;
}