我必須在我的按鈕點擊事件中寫上面的代碼。 webservice工作fine.webservice方法返回一個字符串。 thatString等於成功去下一個layout.it工作正常。但其他部分不起作用。烤麪包做一個例外無法處理webservice方法調用中的線程?
final SoapSerializationEnvelope envelope1 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope1.setOutputSoapObject(request1);
//msg.setText("hi");
envelope1.dotNet = true;
final Thread webser=new Thread(){
public void run()
{
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
System.out.println("four and Object value is : " +androidHttpTransport);
System.out.println("four and URL : " +URL);
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope1);
System.out.println("four a");
// Get the SoapResult from the envelope body.
SoapObject result1 = (SoapObject)envelope1.bodyIn;
if(result1 != null)
{
//Get the first property and change the label text
status=result1.getProperty(0).toString();
if(status.equalsIgnoreCase("success"))
{
Intent home=new Intent(LoginActivity.this,MainActivity.class);
startActivity(home);
}
else
{
Thread.sleep(1000);
Toast.makeText(LoginActivity.this,"Enter Valid Username/Password", Toast.LENGTH_LONG).show();
}
}
else
{
System.out.println("nodata");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception" +e);
}
}
};
webser.start();
}
});
「它不起作用」不足以幫助您描述。請更具描述性。 – JoxTraex 2012-08-04 14:18:04
我必須在我的按鈕點擊事件中寫上面的代碼。 webservice工作fine.webservice方法返回一個字符串。 thatString等於成功去下一個layout.it工作正常。但其他部分不起作用。吐司例外 – Palaniraja 2012-08-04 14:26:59
請在您的文章中明確說明,而不是在評論中。 – JoxTraex 2012-08-04 14:28:42