我正在制作一个Android应用程序,使用json api为输入pnr提供PNR状态。但是当我使用学院wifi访问网络从我的Android手机访问互联网时,所以我使用传统的java线设置代理
System.getProperties().put("http.proxyHost", "10.3.100.211");
System.getProperties().put("http.proxyPort", "8080");
但是当我运行应用程序时,它会突然停止。如果我注释掉这些行没有建立连接,但应用程序运行正常。那么有人可以帮助我如何在我的应用程序中设置代理。
答案 0 :(得分:1)
尝试使用:
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