Csdn download Some questions about the Android program call WebService run unsuccessfully

Source: Internet
Author: User

Today, from the book and csdn to find a few examples of Android call WebService, these examples from the code point of view, there is no error, but the run is not successful. This paper analyzes the writing of the Android calling Web interface, and finds that these examples do not open a thread at the time of the call to run the problem. The following is CSDN download the example "Android query phone number" of the major changes to the code, I hope to learn about the Android beginner is helpful.

futuretask<string> futuretask = new futuretask<string> (new callable<string> () {@Overridepublic String call () throws exception{try{//calls Webservicetransport.call (SOAPAction, envelope); if (Envelope.getresponse ()! = NULL) {//Gets the returned data soapobject object = (soapobject) envelope.bodyin;//Gets the results returned by string result = Object.getproperty (0). ToString (); return result;}} catch (Exception e) {e.printstacktrace ();} return null;}}); New Thread (Futuretask). Start ();//WebService The returned results are displayed in TextView try{string result=futuretask.get (); Resultview.settext (result);} catch (Interruptedexception e) {//TODO auto-generated catch Blocke.printstacktrace ();} catch (Executionexception e) {// TODO auto-generated catch Blocke.printstacktrace ();}

Csdn download Some questions about the Android program call WebService run unsuccessfully

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.