I am developing an app that will work in 2 different Android environments (consumer & corporate markets). Lets say it is a texting app with a dozen configuration parameters to manage.
The first environment is a standard Android device that has no Android Enterprise (AfW) features enabled. So there is no EMM (MDM) to supply an Android Agent/Client app to be a device/profile owner implementing a Managed Configurations Provider.
The second environment is within a corporation. An EMM (MDM) is used to manage all their corporate owned devices. The EMM is either a device or profile owner. They are set up to use Managed Configurations and require remote configuration of this app.
To support both of these cases, how should this app retrieve configurations?
My current thought is to check if the instance of my app belongs to a device or profile owner. If it does, I will use managed configurations. If it doesn't, it will allow on-device, within-the-app configuration using SharedPreferences.
I believe this will work, but seems too much like a hack. It also restricts a company using a device/profile owner from giving their users control. I imagine other Android apps must be starting to encounter this situation with the adoption-rate of Managed Configurations increasing. Is there a better solution for this scenario?
You can always call RestrictionsManager.getApplicationRestrictions(), whether the device is managed or not:
- if the device is managed and the company has configured the app, it will return the configuration,
- if the device is not managed or if the company has not configured the app, it will return an empty
Bundle
and you can give control to the user.
来源:https://stackoverflow.com/questions/45179227/how-to-use-managed-configurations-in-an-app-that-may-not-have-a-managed-configur