Some Questions about the failure of Android program to call Webservice on CSDN

Source: Internet
Author: User

Some Questions about the failure of Android program to call Webservice on CSDN

Today, I found several examples of android webservice calls from books and CSDN. These examples show that there are no errors in the code, but they are not running successfully. After analyzing how android calls the web interface, we find that these examples do not run in a single thread during the call. Below we will post out the main code changes to the example "Android phone number query" downloaded from CSDN, hoping to help beginners who want to learn android.

FutureTask
 
  
FutureTask = new FutureTask
  
   
(New Callable
   
    
() {@ Overridepublic String call () throws Exception {try {// call WebServicetransport. call (soapAction, envelope); if (envelope. getResponse ()! = Null) {// get the returned data SoapObject object = (SoapObject) envelope. bodyIn; // obtain the returned result String result = object. getProperty (0 ). toString (); return result ;}} catch (Exception e) {e. printStackTrace () ;}return null ;}}); new Thread (futureTask ). start (); // display the results returned by WebService 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 ();}
   
  
 

Related Article

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.