返回信息流public void onClickme(String msg){
String nameSpace = "http://WebXml.com.cn/";
String methodName = "getWeatherbyCityName";
String endPoint = "http://webservice.webxml.com.cn/WebServices/WeatherWebService.asmx";
String soapAction = "http://WebXml.com.cn/getWeatherbyCityName";
SoapObject rpc = new SoapObject(nameSpace, methodName);
rpc.addProperty("theCityName", msg);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
String result = "无网络";
try {
transport.call(soapAction, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapObject object = (SoapObject) envelope.bodyIn;
try{
result = object.toString();
}catch(Exception e){}
if(result=="无网络"){
Toast.makeText(MainActivity.this,"无网络连接",2000).show();
}
else{
Bundle bundle = new Bundle();
bundle.putString("data", result);
Intent intent= new Intent();
intent.setClass(MainActivity.this,ResultActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}目前运行连不上网络,去年都可以,求帮助啊
这是一条镜像帖。来源:北邮人论坛 / java / #39932同步于 2015/4/12
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
求大神帮助我的Android毕业论文
liumoude
2015/4/12镜像同步16 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
【 在 icyfox 的大作中提到: 】
: 是不是对方API接口换了,你换个天气API试试
换接口???我自学的,看书本学的,不知道API接口,求指导
【 在 aName 的大作中提到: 】
: exception 是什么错误?
: 通过『我邮2.0』发布
虚拟机运行都没有错误的,可以运行的,但是点击查天气显示无网络