1
您好我正在做一個應用程序的聯繫人應用程序我得到了聯繫人ID和顯示名稱使用下面的代碼現在我想要的是公司名稱與聯繫人ID和顯示name.how我可以得到公司名稱?在android中獲取聯繫人的公司名稱?
private void populateContactList() {
// Build adapter with contact entries
Cursor cursor = getContacts();
fields = new String[] { ContactsContract.Data.DISPLAY_NAME,
ContactsContract.Contacts._ID};
contactqueryAdaptor = new Contactquery_adaptor(this, R.layout.row,
cursor, fields, new int[] { R.id.applese });
}
// getContacts()
private Cursor getContacts() {
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
+ (mShowInvisible ? "0" : "1") + "'";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
}
你能說什麼coloumn Android聯繫人公司的名稱? – Ramz
目前我無法測試這個,但我猜想你需要在''projection'和'fields'數組中包含'ContactsContract.CommonDataKinds.Organization.COMPANY'? – manavo