You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Microsoft Intune MDM/MAM向安卓应用传递自定义键值对配置

安卓应用实现Intune自定义配置(对标iOS键值对配置方式)

Intune后台配置操作

  • 登录Intune控制台,找到你的安卓应用,进入「应用配置策略」
  • 点击「添加」,配置类型选「托管设备上的托管应用」,目标选中你的应用
  • 进入「配置设置」环节,选择「使用自定义JSON」,把需求的配置写成如下格式:
    {
      "qrCode": "{\"applicationName\":\"LoremIpsum\",\"baseUrl\":\"https://LoremIpsum.com.au/01/api/mobile/\"}",
      "acceptTermsAndConditions": true
    }
    

    注意:qrCode的值是嵌套JSON字符串,必须转义双引号,和需求里的格式完全一致

  • 保存策略并分配给目标用户/设备组

安卓应用端接收配置的方法

原生安卓(Kotlin/Java)

  1. 在AndroidManifest.xml中添加meta-data,声明应用支持托管配置:
    <application ...>
      <meta-data
          android:name="com.microsoft.intune.mam.supported_configurations"
          android:resource="@xml/managed_configurations" />
    </application>
    
  2. 在res/xml目录下新建managed_configurations.xml,定义配置项的类型与键名:
    <restrictions xmlns:android="http://schemas.android.com/apk/res/android">
      <restriction
          android:key="qrCode"
          android:title="QR配置字符串"
          android:description="应用初始化用的JSON配置"
          android:restrictionType="string" />
      <restriction
          android:key="acceptTermsAndConditions"
          android:title="是否同意条款"
          android:description="控制应用内条款同意状态"
          android:restrictionType="bool" />
    </restrictions>
    
  3. 在应用内读取配置:
    val config = ManagedConfigurationManager.getConfiguration(applicationContext)
    val qrCode = config.getString("qrCode")
    val acceptTerms = config.getBoolean("acceptTermsAndConditions", false)
    

    若使用安卓原生Work Profile环境,也可通过RestrictionsManager读取,逻辑一致

跨平台应用(以Flutter为例)

借助flutter_intune_mam插件读取配置:

import 'package:flutter_intune_mam/flutter_intune_mam.dart';

Future<void> loadIntuneConfigs() async {
  final configMap = await FlutterIntuneMam.getManagedAppConfig();
  final qrCode = configMap['qrCode'] as String?;
  final acceptTerms = configMap['acceptTermsAndConditions'] as bool?;
  // 获取到配置后即可在应用内使用
}

验证配置生效

  • 将应用上传至Intune并分配给测试设备
  • 安装应用后,通过日志或调试工具检查是否正确获取到两个配置值
  • 若未获取到,先确认Intune策略是否已分配到位,再核对应用内配置项键名与Intune端是否完全一致

内容的提问来源于stack exchange,提问作者Shapebuster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 00:00:00