私のコンピュータがインターネットに接続しようとすると、私はプロキシ、ユーザ名とパスワードを設定しなければなりません。私はAndroid仮想マシンに設定して動作させます(仮想マシンはインターネットにアクセスできます)。しかし、私は私のアプリを実行すると、インターネットにアクセスすることはできません。 誰でも助けてくれますか?ありがとうございます!Android:About android webservice
public class wsActivity extends Activity {
private static final String mNameSpace = "http://WebXml.com.cn/";
private static final String mMethodName = "getWeatherbyCityName";
private static final String mUrl = "http://www.webxml.com.cn/webservices/weatherwebservice.asmx?wsdl";
private static final String SOAP_ACTION = "http://WebXml.com.cn/getWeatherbyCityName";
private String weatherToday = null;
private SoapObject details;
private Button mBtnSearch;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mBtnSearch = (Button)findViewById(R.id.btn_search);
mBtnSearch.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
getWeather("北京");
}
});
}
/**
* getWeather(String cityName)
*
*/
public void getWeather(String cityName){
SoapObject rpc = new SoapObject(mNameSpace, mMethodName);
rpc.addProperty("theCityName", cityName);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
HttpTransportSE ht = new HttpTransportSE(mUrl);
//AndroidHttpTransport ht = new AndroidHttpTransport(mUrl);
ht.debug = true;
Log.d("getWeather","path:"+ht.getPath());
try {
ht.call(SOAP_ACTION, envelope);
details = (SoapObject) envelope.getResponse();
Log.d("getWeather",details.toString());
parseWeather(details);
return;
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
/**
* parseWeather(SoapObject details)
*
*/
public void parseWeather(SoapObject detail) throws UnsupportedEncodingException {
String date = detail.getProperty(6).toString();
weatherToday = "今天:" + date.split(" ")[0];
weatherToday = weatherToday + "\n天气:" + date.split(" ")[1];
weatherToday = weatherToday + "\n气温:"
+ detail.getProperty(5).toString();
weatherToday = weatherToday + "\n风力:"
+ detail.getProperty(7).toString() + "\n";
Toast.makeText(this, weatherToday, Toast.LENGTH_LONG).show();
}
}
マニフェストのインターネットのアクセス許可を設定しましたか – Armand