Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider how you register your observer. The second argument of <code>registerContentObserver</code> is <code>boolean notifyForDescendents</code>, you have set it to <code>true</code>. so you will be notified when either ContactsContract.Contacts.CONTENT_URI or any of its descandants uris were changed. It may be that some operation for contact with given id triggers notification both for the specific contact uri and global contacts uri - with second argument being <code>true</code> your observer observes both.</p> <p>Another thing is that You can register content observer for specific contact id uri - <code>ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId)</code>. This however has nothing to do with your issue but registering separate observer for every contact looks rather ugly ;)</p> <p>Another suggestion: Maybe keep observer as final field not recreate it in onCreate (but only register it there).</p> <pre><code>public class ContactService extends Service { private final ContentObserver contactsObserver = new ContentObserver(null) { @Override public void onChange(boolean selfChange) { super.onChange(selfChange); Log.i("LOG","detected change in contacts: "+selfChange); //your code here } }; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); getContentResolver().registerContentObserver( ContactsContract.Contacts.CONTENT_URI, true, contactsObserver); } @Override public void onDestroy() { getContentResolver().unregisterContentObserver(contactsObserver); super.onDestroy(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload