dhkim1027
8/1/2017 - 4:09 AM

From https://stackoverflow.com/questions/6190779/monitor-android-system-settings-values?lq=1

ContentResolver contentResolver = getContentResolver();
Uri setting = Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION);
ContentObserver observer = new ContentObserver(new Handler()) {
    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
    }

    @Override
    public boolean deliverSelfNotifications() {
        return true;
    }
};
contentResolver.registerContentObserver(setting, false, observer);
contentResolver.unregisterContentObserver(observer);