Reputation: 9520
I m developing application in which i want to get the notification for contact change with ID.
Upvotes: 1
Views: 2532
Reputation: 111
Use ContentObserver.
@Override
public void onChange (boolean selfChange)
{
this.onChange(selfChange, null);
}
@Override
public void onChange (boolean selfChange,Uri uri)
{
Cursor cursor = mCntxt.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null,null,ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP + " Desc");
if (cursor.moveToNext()) {
String id = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Log.w("Contact ID", id);
Log.w("Person Name",name);
}
}
Hope it helps....
Upvotes: 1
Reputation: 542
Getting the notification is very simple. i also searched a lot for the same stuff. I could not find any solution. Content observer notifies that there is a change in your contact. You have to use some contact id comparison technique to find out the proper solution. Good luck
Upvotes: 1
Reputation: 961
The ContentObserver
class http://developer.android.com/reference/android/database/ContentObserver.html is meant for this job, but does not give you change of ID, only the total change.
You are stuck by implementing that a pre-handler vs post-handler to see what changed yourself.
Upvotes: 0