5

I'm trying to create a BroadCast receiver that listen any changes of system settings to update a UI.

I wrote a series of action in intent-filter on my android manifest in this way:

<receiver android:name=".Receiver_OnSettingChange">
    <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            <action android:name="android.intent.action.AIRPLANE_MODE" />
            <action android:name="android.media.RINGER_MODE_CHANGED" />
            <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
            <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
            <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
            <action android:name="android.intent.action.BATTERY_CHANGED" />
            <action android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
            <action android:name="android.net.conn.BACKGROUND_DATA_SETTING_CHANGED" />
            <action android:name="com.android.internal.telephony.MOBILE_DATA_CHANGED" />
            <action android:name="com.android.settings.GPS_STATUS_CHANGED" />
            <action android:name="android.nfc.action.ADAPTER_STATE_CHANGE" />
            <action android:name="android.location.PROVIDERS_CHANGED" />
            <action android:name="android.intent.action.USER_PRESENT" />
            <action android:name="com.android.sync.SYNC_CONN_STATUS_CHANGED" />                 
            <action android:name="android.intent.action.MEDIA_SCANNER_FINISHED" />
            <action android:name="android.intent.action.MEDIA_SCANNER_STARTED" />
            <action android:name="android.intent.action.MEDIA_UNMOUNTED" />
            <action android:name="android.intent.action.MEDIA_EJECT" />
            <action android:name="android.intent.action.MEDIA_MOUNTED" />
    </intent-filter>
    </receiver>

but I need to listen every single system settings change (like "auto rotation" from on to off or vice versa, brightness from auto to off or anything else and the others).

If there is an action that I can write in the manifest is better for me.

Many thanks

Meroelyth
  • 5,310
  • 9
  • 42
  • 52

2 Answers2

2

There is indeed a way to do this but it's not with a broadcast receiver. You need to use an observer. I do this in Audio Control and it works almost perfect. Once in a while something will be changed that I don't pick up but that is rare. Here is a link that gives some details on how to implement.

Settings Observer

Community
  • 1
  • 1
Matthew
  • 3,411
  • 2
  • 28
  • 28
1

but I need to listen every single system settings change (like "auto rotation" from on to off or vice versa, brightness from auto to off or anything else and the others).

Most do not have broadcast Intents associated with them, sorry.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks, but there is a list of all intents assciated with system settings? – Meroelyth Apr 29 '12 at 13:52
  • @Meroelyth: Not in the SDK documentation, sorry. – CommonsWare Apr 29 '12 at 13:55
  • @CommonsWare: I have the same problem as Meroelyth above. How would you check if the user has manually clicked the "Auto Rotation" button in the notification bar in that case? – ChuongPham Aug 13 '12 at 17:35
  • in the sdk directory, under the folder platforms\android-X\data there is the file broadcast_actions.txt containing a lot of broad actions sent by the system. i don't know if them are all of the possible broadcast, but should be a good point of start. hope this help – Apperside Dec 01 '12 at 21:26