简体   繁体   English

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

[英]Using Proxy Server in Android Application

I am making an Android Application for giving PNR status to the input pnr using a json api. 我正在制作一个Android应用程序,使用json API将PNR状态赋予输入pnr。 But as I am using institute wifi to access network for accessing internet from my android cell phone, so I had set up proxy using the conventional java lines 但是由于我使用学院wifi来访问网络以从我的android手机访问互联网,因此我已经使用常规的java行设置了代理

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

But when I run the application it abruptly stops. 但是,当我运行该应用程序时,它突然停止了。 If I comment out the lines the connection is not established but the application runs fine. 如果我注释掉这些行,则表示未建立连接,但应用程序运行良好。 So could someone help me in how to set up proxy in my application. 因此有人可以帮助我如何在我的应用程序中设置代理。

Try using: 尝试使用:

  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 http://developer.android.com/reference/java/lang/System.html#setProperties%28java.util.Properties%29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM