Reputation: 2311
I have to execute a peace of code on new contact found,So I'm using service to check whether new contact found in the ContactList.My question is-How can we get new contact added in ContactList?
Upvotes: 1
Views: 671
Reputation: 53657
Step-1 Create your own content observer and register it to detect any type of contact change
getApplication().getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true,new MyContentObserver());
Step-2 Write your own logic to detect contact addition if new contact id is added.
Example: Re-query a cursor to the Contacts table each time the ContentObserver changes and maintain the highest known CONTACT_ID value. The newly added contact will have the id which you have stored before
Upvotes: 1