Java Code Examples for android.provider.ContactsContract.RawContacts#DISPLAY_NAME_PRIMARY

The following examples show how to use android.provider.ContactsContract.RawContacts#DISPLAY_NAME_PRIMARY . 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: ContactListFragment.java    From haxsync with GNU General Public License v2.0 6 votes vote down vote up
@Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      
      setEmptyText(getActivity().getString(R.string.no_contacts));
      setHasOptionsMenu(true);


String[] columns = new String[] {RawContacts.DISPLAY_NAME_PRIMARY};
int[] to = new int[] { android.R.id.text1 };
mAdapter = new ContactsCursorAdapter(
        getActivity(),
        android.R.layout.simple_list_item_activated_1, 
        null,
        columns,
        to,
        0);
setListAdapter(mAdapter);
showSyncIndicator();
   mContentProviderHandle = ContentResolver.addStatusChangeListener(
             ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE, this);

  }
 
Example 2
Source File: ContactsDatabase.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private @NonNull Map<String, SignalContact> getSignalRawContacts(@NonNull Account account) {
  Uri currentContactsUri = RawContacts.CONTENT_URI.buildUpon()
                                                  .appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
                                                  .appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type).build();

  Map<String, SignalContact> signalContacts = new HashMap<>();
  Cursor                     cursor         = null;

  try {
    String[] projection = new String[] {BaseColumns._ID, RawContacts.SYNC1, RawContacts.SYNC4, RawContacts.CONTACT_ID, RawContacts.DISPLAY_NAME_PRIMARY, RawContacts.DISPLAY_NAME_SOURCE};

    cursor = context.getContentResolver().query(currentContactsUri, projection, null, null, null);

    while (cursor != null && cursor.moveToNext()) {
      String  currentAddress              = PhoneNumberFormatter.get(context).format(cursor.getString(1));
      long    rawContactId                = cursor.getLong(0);
      long    contactId                   = cursor.getLong(3);
      String  supportsVoice               = cursor.getString(2);
      String  rawContactDisplayName       = cursor.getString(4);
      String  aggregateDisplayName        = getDisplayName(contactId);
      int     rawContactDisplayNameSource = cursor.getInt(5);

      signalContacts.put(currentAddress, new SignalContact(rawContactId, supportsVoice, rawContactDisplayName, aggregateDisplayName, rawContactDisplayNameSource));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return signalContacts;
}
 
Example 3
Source File: ContactListFragment.java    From haxsync with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
	Activity ac = getActivity();
	AccountManager am = AccountManager.get(ac);
	Account account = am.getAccountsByType(ac.getString(R.string.ACCOUNT_TYPE))[0];
	Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
				.appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
				.appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type)
				.build();

	return new CursorLoader(ac, rawContactUri,
			new String[] {RawContacts._ID, RawContacts.DISPLAY_NAME_PRIMARY},
			null, null, RawContacts.DISPLAY_NAME_PRIMARY + " ASC");
}