How to use Managed Configurations in an app that may not have a Managed Configurations Provider?

强颜欢笑 提交于 2019-12-20 03:13:36

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!