Welcome to Headwind MDM Q&A, where you can ask questions and receive answers from other members of the community.

Please do not post bug reports, missing feature requests, or demo inquiries. If you have such an inquiry, submit a contact form.

0 votes

I am developing a custom Android application integrated with Headwind MDM. I set up settings as the "Application settings"

How to notify the application when the settings are changed on the server?

by

1 Answer

0 votes

When the configuration is changed, Headwind MDM sends a broadcast "com.hmdm.push.configUpdated" to every connected application.

Here's the code you must add to your application's MainActivity:

1. Define a BroadcastReceiver which handles the broadcast:

    private BroadcastReceiver configUpdateReceiver = new BroadcastReceiver() {

        @Override

        public void onReceive(Context context, Intent intent) {

            if (intent.getAction().equals("com.hmdm.push.configUpdated")) {

                // Reload your settings from the MDM

String setting_one = MDMService.Preferences.get("my_setting_one", "default_value");

...

// Refresh your application and apply new settings

...

            }

        }

    };

2. Register this broadcast receiver after the activity is created:

    @Override

    protected void onCreate(Bundle savedInstanceState) {

...

// Register your receiver

        registerReceiver(configUpdateReceiver, new IntentFilter(Const.NOTIFICATION_CONFIG_UPDATED));

    }

3. Unregister the broadcast receiver when the activity is destroyed to avoid resource leak:

    @Override

    protected void onDestroy() {

        super.onDestroy();

        unregisterReceiver(configUpdateReceiver);

    }

by (32.7k points)
...