Getting the state and state changes of phone settings

This topic describes how to get the state and state changes pertaining to various phone settings.

Steps

  1. Subscribe to SettingListener using Setting.subscribeListener() method.

    //Sample code to subscribe to  state changes pertaining to various phone settings.
    
    try {
        Setting.subscribeListener(this);
    }
    catch (Exception e) {
    }
  2. Implement the SettingListener interface by defining the SettingListener.settingChanged() method.

    // Sample code implementing the SettingListener interface
    
    public void settingChanged(int setting, int value) {
         form.append("Getting state changes of phone settings. Setting is : " + setting + " and it's value is : " + value);
    }
    
  3. Get the state of the phone setting you require using the Setting.getSetting() method.

    //Sample code to get the state of flight mode
    
    Setting.getSetting(Setting.SETTING_FLIGHT_MODE);