Toggle Charles Proxy On Android From Command-Line

Once you've done all the initial configuration to route HTTP and HTTPS traffic from your Android device through Charles, as described here and here, you might find yourself wanting to quickly enable and disable this network proxy on your device. Manually adding and removing proxy settings via Android's built-in wifi config UI is time-consuming and slightly cumbersome. Wouldn't it be better if you could just do this from the command-line? You can! And it's actually quite simple.


Warning: This uses a feature that's typically reserved for administrators within a workplace or other organization that owns your device. Once you enable this global proxy, you can't manually disable it from your device; be sure to disable it via adb before walking off with your phone and using it for other purposes.


Enable & Disable Global HTTP Proxy For Charles Monitoring

Enable proxy:
adb shell settings put global http_proxy <host>:<port>

Check setting:
adb shell settings get global http_proxy

Disable proxy (takes effect right away):
adb shell settings put global http_proxy :0

Delete the global setting (takes effect on restart or in response to PROXY_CHANGE broadcast):
adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port


If you found this helpful, you'd like to thank me, and you enjoy reading sci-fi -- or know someone who does -- buy a copy of Upload!


comments powered by Disqus