我正在尝试使用MobileIron EMM为我的应用设置远程配置。我已经按照开发者指南的描述完成了以下步骤: 1. 我已经设置了清单文件:
...
<meta-data
android:name="android.content.APP_RESTRICTIONS"
android:resource="@xml/app_restrictions"/>
</application>
2. 我已经描述了限制:
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:title="@string/some_title"
android:key="SOME_KEY"
android:restrictionType="string"
android:defaultValue="123"/>
</restrictions>
3. 我正在尝试按照以下方式接收它:
RestrictionsManager manager = (RestrictionsManager) context.getSystemService(Context.RESTRICTIONS_SERVICE);
Bundle b = manager.getApplicationRestrictions();
if(b!=null){
if(b.containsKey("SOME_KEY")) {
return b.getString("SOME_KEY");
}else{
System.out.println("bundle is not null");
for (String s: b.keySet()){
System.out.println("key in b is : " + s);
}
System.out.println(b.isEmpty() + " bundle is empty");
}
}else{
System.out.println("Bundle is null");
}
return "";
}
我总是得到这个输出:
bundle is not null
true bundle is empty
虽然我已经设置了限制的默认值,但为什么我没有得到至少限制的默认值?为什么我从未得到实际值(在服务器端,我使用MobileIron Cloud及其AppConnect配置设置了这些值)?我已经尝试了几个设备。我错过了什么?请帮忙。我的目标是远程向应用程序设置一些键值。