Reputation: 7517
When a change is made to any contact in the default contacts app in android is it possible to know to which contact the change was made or at least what information was changed or anything related to it?
Upvotes: 0
Views: 40
Reputation: 1857
You are able to know the Contact is Updated but not able to Know which Contact is updated as content observers don't tell you which one changed you have to find out by querying and comparing with old data.
You can used the following code to identify the Contact is updated.
public class UpdateActivity extends Activity {
Button registerbutton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
registerbutton=(Button)findViewById(R.id.button1);
registerbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getContentResolver()
.registerContentObserver(
ContactsContract.Contacts.CONTENT_URI, true,
new MyCOntentObserver());
}
});
}
public class MyCOntentObserver extends ContentObserver{
public MyCOntentObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Log.e("","~~~~~~"+selfChange);
}
@Override
public boolean deliverSelfNotifications() {
return true;
}
}
}
Upvotes: 1