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);
}