contactscontract

How to get contacts with which the user talks often?

删除回忆录丶 提交于 2019-12-04 07:16:31
Is it possible using ContactsContract to get contacts with which the user talks often? I know I can use the CallLog ContentProvider and try to figure that out, but I wanted to know if there is already a way to do it. The number of times a contact has been contacted ContactsContract.Contacts.times_contacted static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.STARRED, ContactsContract.Contacts.TIMES_CONTACTED, ContactsContract.Contacts.CONTACT_PRESENCE, ContactsContract.Contacts.PHOTO

Android contacts custom field

半城伤御伤魂 提交于 2019-12-04 04:42:58
问题 Is it possible to add custom field to some contacts, with custom mimetype (like facebook profile) without writing sync adapter, authenticator and sync service? I do not want to add "synchronization" functionality for my application. 回答1: After long research I think that I found an answer to this question. There is no way of creating custom clickable and visible fields without writing some Synchronization service code, authenticator and syncAdapter. Here is sample code which is adding new

Get all contacts and their details (e.g. postal address) in one OUTER JOIN query

Deadly 提交于 2019-12-04 04:17:54
问题 I know how to retrieve contact data for specific contacts. However, i can't find a way to get all contacts plus some of their details in a single query. The following code gets all contacts having a postal address: Uri uri = ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI; String[] projection = new String[] { StructuredPostal._ID, StructuredPostal.LOOKUP_KEY, StructuredPostal.DISPLAY_NAME, StructuredPostal.STREET, StructuredPostal.CITY }; String sortOrder = StructuredPostal

How to add structured data to a new contact Intent

青春壹個敷衍的年華 提交于 2019-12-04 03:43:30
I need to support Android 2.1 and up. Google posted an example of how to use the ContactsContract, but some of it used things that are available starting with API level 11, so I need to improvise, but I'm stuck. So, far I have this: String firstName = contactProperties.get("firstName"); String lastName = contactProperties.get("lastName"); String phone = contactProperties.get("phone"); String email = contactProperties.get("email"); String company = contactProperties.get("company"); String postal = contactProperties.get("street") + ", " + contactProperties.get("city") + ", " + contactProperties

Retrieval of firstname and lastname from android contacts results in '1' and 'null'

时光总嘲笑我的痴心妄想 提交于 2019-12-03 13:55:24
问题 I am retrieving firstname and lastname from the android contact using the below code.DISPLAY_NAME gives back the name of the contact while firstname and lastname returns 1 and null respectively.The following is the code. ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,null, null, null); if (cur.getCount() > 0) { while (cur.moveToNext()) { String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); String name = cur

What does COLLATE LOCALIZED ASC stand for?

孤街浪徒 提交于 2019-12-03 09:27:37
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); } What does COLLATE LOCALIZED ASC stand for? Collate is just fancy speak for sort (well sort of)

Getting RawContact id using Contact id

无人久伴 提交于 2019-12-03 08:46:42
I have built the following method to obtain the id from the RawContacts table using the id obtained from the Contacts table.This method fails thrwoing an Exception. public int getRawContactId(int contactId) { String[] projection=new String[]{ContactsContract.RawContacts._ID}; String selection=ContactsContract.RawContacts.CONTACT_ID+"=?"; String[] selectionArgs=new String[]{String.valueOf(contactId)}; Cursor c=context.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI,projection,selection,selectionArgs , null); int rawContactId=c.getInt(c.getColumnIndex(ContactsContract

How to show custom type contact inside Contact like WhatsApp android

大城市里の小女人 提交于 2019-12-03 07:58:01
/** * Account type id */ public static final String ACCOUNT_TYPE = "com.test.app"; /** * Account name */ public static final String ACCOUNT_NAME = "Test"; public static void addContact(Context context, User contact) { ContentResolver resolver = context.getContentResolver(); resolver.delete(RawContacts.CONTENT_URI, RawContacts.ACCOUNT_TYPE + " = ?", new String[] { AccountConstants.ACCOUNT_TYPE }); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation .newInsert( addCallerIsSyncAdapterParameter( RawContacts.CONTENT_URI, true))

Retrieval of firstname and lastname from android contacts results in '1' and 'null'

☆樱花仙子☆ 提交于 2019-12-03 03:47:10
I am retrieving firstname and lastname from the android contact using the below code.DISPLAY_NAME gives back the name of the contact while firstname and lastname returns 1 and null respectively.The following is the code. ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,null, null, null); if (cur.getCount() > 0) { while (cur.moveToNext()) { String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); if (Integer.parseInt(cur

How to create a contact programmatically [duplicate]

柔情痞子 提交于 2019-12-03 00:53:05
This question already has answers here : How to add new contacts in android (5 answers) Possible Duplicate: How to add new contacts in android public boolean createContact(String name, String number, String email) { boolean success = true; try { ContentValues contentValues = new ContentValues(); ContentResolver contentResolver = getContentResolver(); contentValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); contentValues.put(Phone.NUMBER, "123254"); Uri uri = contentResolver.insert(android.provider.ContactsContract.Data.CONTENT_URI, contentValues); if(uri==null) { success = false; } } catch