title: Monitor Android system settings values
body: <p>I want to watch a system setting and get notified when its value changes. The Cursor class has a <a href="http://developer.android.com/reference/android/database/Cursor.html#setNotificationUri%28android.content.ContentResolver,%20android.net.Uri%29" rel="noreferrer">setNotificationUri</a> method which sounded nice, but it doesn't work and coding it also feels strange... Thats what I did:</p>
  
  <pre><code>    // Create a content resolver and add a listener
      ContentResolver resolver = getContentResolver();
      resolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS | ContentResolver.SYNC_OBSERVER_TYPE_PENDING | ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE, new MyObserver());
  
      // I somehow need to get an instance of Cursor to use setNotificationUri in the next step...
      Cursor cursor2 = resolver.query(Settings.System.CONTENT_URI, null, null, null, null);
  
      // For testing purposes monitor all system settings
      cursor2.setNotificationUri(resolver, Settings.System.CONTENT_URI);
  </code></pre>
  
  <p>The listener:</p>
  
  <pre><code>public class MyObserver implements SyncStatusObserver {
  
  public void onStatusChanged(int which) {
      Log.d("TEST", "status changed, which = " + which);
  
  }
  }
  </code></pre>
  
  <p>Well, obviously the listener gets never called, I can't find an entry with the specified TEST tag in logcat ): (For testing I manually changed the brightness setting from manual to automatic in the android settings menu). Any hint what I am doing wrong? Any other, better way to monitor Android system settings?</p>
  
  <p>Thanks for any hint!</p>