gpt4 book ai didi

java - 在 Android 应用程序中使用代理服务器

转载 作者:行者123 更新时间:2023-12-01 13:46:14 25 4
gpt4 key购买 nike

我正在制作一个 Android 应用程序,用于使用 json api 将 PNR 状态提供给输入 pnr。但是由于我使用学院wifi来访问网络以从我的android手机访问互联网,所以我使用传统的java线路设置了代理

System.getProperties().put("http.proxyHost", "10.3.100.211");
System.getProperties().put("http.proxyPort", "8080");

但是当我运行该应用程序时,它突然停止了。如果我注释掉这些行,则不会建立连接,但应用程序运行正常。那么有人可以帮助我如何在我的应用程序中设置代理吗?

最佳答案

尝试使用:

  public static String setProperty (String name, String value)


Sets the value of a particular system property.
Returns the old value of the property or null if the property didn't exist.

http://developer.android.com/reference/java/lang/System.html#setProperties%28java.util.Properties%29

关于java - 在 Android 应用程序中使用代理服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20356262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com