Change a flag's value at runtime

After building Android, ensure that you can change the aconfig flag's value.

To change an aconfig flag value at runtime:

  1. Ensure your device is running and connected to your development machine.
  2. Check to see the flag's current setting:

    adb shell aflags list | grep package.flagname
    
  3. If the flag is enabled and your code is executing, continue with step 4 to disable the flag. If the flag is disabled, skip to step 6 to enable your code.

  4. Disable your code. From the command line, run:

      adb shell aflags disable your.full.flag.name
    

    For example, to disable the append_injected_content flag, run:

    adb shell aflags disable com.example.android.aconfig.demo.flags.append_injected_content
    
  5. Skip to step 7.

  6. Enable your code. From the command line, run:

    adb shell aflags enable your.full.flag.name
    

    For example, enable the append_injected_content flag, run:

    adb shell aflags enable com.example.android.aconfig.demo.flags.append_injected_content
    
  7. Reboot the device:

    adb reboot
    
  8. Check the status your code either by attempting to execute it on the device or by rerunning the aflags list command again:

    adb shell aflags list | grep package.flagname
    

    If your code was enabled, it should be disabled. Conversely, if your code was disabled, it should be enabled.