當前位置: 首頁>>代碼示例>>Java>>正文


Java Contacts.DISPLAY_NAME屬性代碼示例

本文整理匯總了Java中android.provider.ContactsContract.Contacts.DISPLAY_NAME屬性的典型用法代碼示例。如果您正苦於以下問題:Java Contacts.DISPLAY_NAME屬性的具體用法?Java Contacts.DISPLAY_NAME怎麽用?Java Contacts.DISPLAY_NAME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.provider.ContactsContract.Contacts的用法示例。


在下文中一共展示了Contacts.DISPLAY_NAME屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAllContactsEmailAddressesInfo

@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;
}
 
開發者ID:Kamshak,項目名稱:foursquared,代碼行數:20,代碼來源:AddressBookUtils5.java

示例2: asyncQueryDisplayName

private void asyncQueryDisplayName(final Uri lookupUri)
{
    final String DISPLAY_NAME_COL = Build.VERSION.SDK_INT
          >= Build.VERSION_CODES.HONEYCOMB ?
          Contacts.DISPLAY_NAME_PRIMARY :
          Contacts.DISPLAY_NAME;

    final String[] projection = new String[] {
          Contacts._ID,
          DISPLAY_NAME_COL,
    };

    NotifyingAsyncQueryHandler asyncQuery = new NotifyingAsyncQueryHandler(this, this);
    asyncQuery.startQuery(1, lookupUri,
        lookupUri,
        projection,
        null,
        null,
        null);
}
 
開發者ID:bdiegel,項目名稱:android-giftwise,代碼行數:20,代碼來源:MainActivity.java

示例3: onActivityCreated

@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);

	setHasOptionsMenu(true);
	
	getLoaderManager().initLoader(0, null, this);
	
	mAdapter = new IndexedListAdapter(
			this.getActivity(),
			R.layout.list_item_contacts,
			null,
			new String[] {Contacts.DISPLAY_NAME},
			new int[] {R.id.display_name});

	setListAdapter(mAdapter);
	getListView().setFastScrollEnabled(true);

}
 
開發者ID:vaslabs,項目名稱:SDC,代碼行數:19,代碼來源:ContactsListFragment.java

示例4: onCreateLoader

public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // This is called when a new Loader needs to be created.  This
    // sample only has one Loader, so we don't care about the ID.
    // First, pick the base URI to use depending on whether we are
    // currently filtering.
    Uri baseUri;
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:22,代碼來源:LoaderRetained.java

示例5: onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up our adapter
    mAdapter = new MyExpandableListAdapter(
            this,
            android.R.layout.simple_expandable_list_item_1,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { Contacts.DISPLAY_NAME }, // Name for group layouts
            new int[] { android.R.id.text1 },
            new String[] { Phone.NUMBER }, // Number for child layouts
            new int[] { android.R.id.text1 });

    setListAdapter(mAdapter);

    mQueryHandler = new QueryHandler(this, mAdapter);

    // Query for people
    mQueryHandler.startQuery(TOKEN_GROUP, null, Contacts.CONTENT_URI, CONTACTS_PROJECTION, 
            Contacts.HAS_PHONE_NUMBER + "=1", null, null);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:22,代碼來源:ExpandableList2.java

示例6: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get a cursor with all people
    Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
            CONTACT_PROJECTION, null, null, null);
    startManagingCursor(c);

    ListAdapter adapter = new SimpleCursorAdapter(this,
            // Use a template that displays a text view
            android.R.layout.simple_list_item_1,
            // Give the cursor to the list adatper
            c,
            // Map the NAME column in the people database to...
            new String[] {Contacts.DISPLAY_NAME},
            // The "text1" view defined in the XML template
            new int[] {android.R.id.text1});
    setListAdapter(adapter);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:20,代碼來源:List2.java

示例7: onActivityCreated

@Override public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Give some text to display if there is no data.  In a real
    // application this would come from a resource.
    setEmptyText("No phone numbers");

    // We have a menu item to show in action bar.
    setHasOptionsMenu(true);

    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_2, null,
            new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
            new int[] { android.R.id.text1, android.R.id.text2 }, 0);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);

    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:24,代碼來源:LoaderCursor.java

示例8: queryAllContacts

/**
 * Synchronously query for contacts in the Contacts
 * ContentProvider.
 */
public Cursor queryAllContacts(ContentResolver cr) {
    // Columns to query.
    final String columnsToQuery[] =
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };
	
    // Contacts to select.
    final String selection = 
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Perform a synchronous (blocking) query on the
    // ContactsContentProvider.
    return cr.query(ContactsContract.RawContacts.CONTENT_URI, 
                    columnsToQuery, 
                    selection,
                    null, 
                    ContactsContract.Contacts._ID
                    + " ASC");
}
 
開發者ID:juleswhite,項目名稱:mobilecloud-15,代碼行數:32,代碼來源:QueryContactsCommand.java

示例9: onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gallery_2);

    // Get a cursor with all people
    Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
            CONTACT_PROJECTION, null, null, null);
    startManagingCursor(c);

    SpinnerAdapter adapter = new SimpleCursorAdapter(this,
    // Use a template that displays a text view
            android.R.layout.simple_gallery_item,
            // Give the cursor to the list adatper
            c,
            // Map the NAME column in the people database to...
            new String[] {Contacts.DISPLAY_NAME},
            // The "text1" view defined in the XML template
            new int[] { android.R.id.text1 });

    Gallery g = (Gallery) findViewById(R.id.gallery);
    g.setAdapter(adapter);
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:23,代碼來源:Gallery2.java

示例10: getContactsByGroup

@Override
public Cursor getContactsByGroup(Context ctxt, String groupName) {

    if (TextUtils.isEmpty(groupName)) {
        return null;
    }

    String[] projection;
    if (Compatibility.isCompatible(11)) {
        projection = new String[] {
                Contacts._ID,
                Contacts.DISPLAY_NAME,
                Contacts.PHOTO_ID,
                Contacts.CONTACT_STATUS_ICON,
                Contacts.CONTACT_STATUS,
                Contacts.CONTACT_PRESENCE,
                Contacts.PHOTO_URI
        };
    } else {
        projection = new String[] {
                Contacts._ID,
                Contacts.DISPLAY_NAME,
                Contacts.PHOTO_ID,
                Contacts.CONTACT_STATUS,
                Contacts.CONTACT_PRESENCE
        };
    }

    Uri searchUri = Uri.withAppendedPath(Contacts.CONTENT_GROUP_URI, Uri.encode(groupName));
    
    
    Cursor c = null;
    try {
        c = ctxt.getContentResolver().query(searchUri, projection, null, null,
                Contacts.DISPLAY_NAME + " ASC");
    } catch(Exception e) {
        Log.e(THIS_FILE, "Error while retrieving group", e);
    }
    return c;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:40,代碼來源:ContactsUtils5.java

示例11: onActivityCreated

@Override public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // In this sample we are going to use a retained fragment.
    setRetainInstance(true);

    // Give some text to display if there is no data.  In a real
    // application this would come from a resource.
    setEmptyText("No phone numbers");

    // We have a menu item to show in action bar.
    setHasOptionsMenu(true);

    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_list_item_2, null,
            new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
            new int[] { android.R.id.text1, android.R.id.text2 }, 0);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);

    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:27,代碼來源:LoaderRetained.java

示例12: onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    Cursor c =
            getContentResolver().query(Contacts.CONTENT_URI, CONTACTS_SUMMARY_PROJECTION, select,
            null, Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
    startManagingCursor(c);
    ContactListItemAdapter adapter = new ContactListItemAdapter(this, R.layout.quick_contacts, c);
    setListAdapter(adapter);

}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:14,代碼來源:QuickContactsDemo.java

示例13: execute

/**
 * Asynchronously query the contacts based on selection
 * criteria.
 */
@Override
public void execute() {
    // Columns to query.
    final String columnsToQuery[] = 
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };

    // Contacts to select.
    final String selection = 
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Initiate an asynchronous query.
    getArgs().getAdapter()
             .startQuery(this,
                         0,
                         ContactsContract.Contacts.CONTENT_URI, 
                         columnsToQuery, 
                         selection,
                         // ContactsContract.Contacts.STARRED /* + "= 0" */,
                         null, 
                         ContactsContract.Contacts._ID
                         + " ASC");        
}
 
開發者ID:juleswhite,項目名稱:mobilecloud-15,代碼行數:36,代碼來源:QueryContactsCommand.java

示例14: onCreateLoader

/**
 * This hook method is called back by the LoaderManager when the
 * LoaderManager is initialized.
 */
public Loader<Cursor> onCreateLoader(int id, 
                                     Bundle args) {
    // Columns to query.
    final String columnsToQuery[] =
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };
	
    // Contacts to select.
    final String selection =
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Create a new CursorLoader that will perform the query
    // asynchronously.
    return new CursorLoader(mOps.getActivityContext(),
                            ContactsContract.Contacts.CONTENT_URI,
                            columnsToQuery,
                            selection,
                            null,
                            Contacts._ID 
                            + " ASC");
}
 
開發者ID:juleswhite,項目名稱:mobilecloud-15,代碼行數:34,代碼來源:QueryContactsCommand.java

示例15: doQuery

private Cursor doQuery(final CharSequence constraint,final int limit,final Long directoryId)
{
String constraintStr=constraint.toString();
final Uri.Builder builder;
String selection=null;
String[] selectionArgs=null;
if(mQuery!=Queries.PHONE)
  builder=mQuery.getContentFilterUri().buildUpon().appendPath(constraintStr);
else
  {
  builder=mQuery.getContentUri().buildUpon();
  // search for either contact name or its phone number
  selection=Contacts.DISPLAY_NAME+" LIKE ? OR "+Phone.NUMBER+" LIKE ?";
  constraintStr="%"+constraintStr+"%";
  selectionArgs=new String[] {constraintStr,constraintStr};
  }
builder.appendQueryParameter(ContactsContract.LIMIT_PARAM_KEY,String.valueOf(limit+ALLOWANCE_FOR_DUPLICATES));
if(directoryId!=null)
  builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,String.valueOf(directoryId));
if(mAccount!=null)
  {
  builder.appendQueryParameter(PRIMARY_ACCOUNT_NAME,mAccount.name);
  builder.appendQueryParameter(PRIMARY_ACCOUNT_TYPE,mAccount.type);
  }
// final long start = System.currentTimeMillis();
final Uri uri=builder.build();
final Cursor cursor=mContentResolver.query(uri,mQuery.getProjection(),selection,selectionArgs,null);
// final long end = System.currentTimeMillis();
// if (DEBUG) {
// Log.d(TAG, "Time for autocomplete (query: " + constraint + ", directoryId: " + directoryId
// + ", num_of_results: " + (cursor != null ? cursor.getCount() : "null") + "): " + (end - start)
// + " ms");
// }
return cursor;
}
 
開發者ID:AndroidDeveloperLB,項目名稱:ChipsLibrary,代碼行數:35,代碼來源:BaseRecipientAdapter.java


注:本文中的android.provider.ContactsContract.Contacts.DISPLAY_NAME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。