一、使用全局命令
设置代理:
adb shell settings put global http_proxy 代理IP地址:端口号
如:
adb shell settings put global http_proxy 127.0.0.1:8888
移除代理:
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
注意:移除代理后要重启手机才能生效。设置代理可以多次设置,立即生效。
在实际操作中有些安卓版本的系统会遇到
settings delete global http_proxy
Invalid command: delete
解决办法
#清空代理设置
settings put global http_proxy :
settings put global global_http_proxy_host “”
settings put global global_http_proxy_port “”
#重启
reboot