没有错误,但没有执行后尝试catch语句
问题描述:
我想显示数据使用Web服务。该代码没有给出错误,但按钮点击执行发生最多只能尝试的一部分,没有什么超出了是执行没有错误,但没有执行后尝试catch语句
try {
Toast.makeText(getApplicationContext(), "You r in try", Toast.LENGTH_LONG).show();
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION1, envelope);
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
//from here nothing executes but gives no error
****if(result != null**)
{
Toast.makeText(getApplicationContext(), "You r in if", Toast.LENGTH_LONG).show();
//Get the first property and change the label text
tv1.setText(result.getProperty(0).toString());
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
答
你调用抛出异常的几种方法。
“跳过”代码表示抛出了异常。
在catch块中放置面包以确认。
+0
androidHttpTransport.call(SOAP_ACTION1,envelope);这行代码没有被执行休息,我通过放置烤面包来检查。 – 2013-02-11 10:16:36
+0
我有一个更具体的问题:如果你在catch块中放了一个烤面包,你会看到烤面包吗?如果你这样做,那么抛出异常。 – chr 2013-02-12 01:03:25
您是否尝试过烘烤结果?您是如何得到 – Payal 2013-02-09 11:13:44
清洁您的项目,然后再试一次。也不用烤面包。使用Log.i(“TAG”,“Your message”); – 2013-02-09 11:14:34
为什么不调试应用程序并在有问题的区域放置断点? – 2013-02-09 12:07:12