Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8106137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:22:33+00:00 2026-06-06T00:22:33+00:00

I am developing an android application that consumes web service , the service output

  • 0

I am developing an android application that consumes web service , the service output is XML

I am connecting to the web service using this code

public  String converse(String host, int port, String path)
            throws IOException, URISyntaxException {
    
        BufferedReader in = null;
        String serviceResponse = null ;
        try {
            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet();
            String serviceUrl = "http://"+host+":"+port+path;
            System.out.println("service url "+serviceUrl);
            request.setURI(new URI(serviceUrl));
            
            System.out.println("Request "+request.toString());
            HttpResponse response = client.execute(request);
            
            in = new BufferedReader
            (new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();
            serviceResponse  = sb.toString();
            
            } finally {
            if (in != null) {
                try {
                    in.close();
                    } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return serviceResponse;
    }

when the application launches with WI-FI every thing works fine and when I restart the application with 3G connection it hangs and displays a the following dialog
waiting dialog in android

In addition to this code I am using this method inside another method

public void fillAdapter() {
        //calling web service using the mentioned method
    }

And this function used inside an async task to fill ListView adapter

protected class AsyncLoading extends AsyncTask<Void,Void, BaseModel[]>{
         
        @Override 
        protected void onPreExecute(){
            pd =ProgressDialog.show(BaseListActivity.this, "loading in progress", "waiting .");
        }
        @Override
        protected BaseModel[] doInBackground(Void... params) {
            fillAdapter();
            return listItems;
    
        }
        @Override
        protected void onPostExecute(BaseModel[] doc){
            //list.setAdapter(doc);
            if(doc != null) {
            if(doc.length > 0 ) {
                if(doc[0] instanceof Activity)
                    adapter = new OffersListAdapter(getApplicationContext(),doc);
                else if (doc[0] instanceof Offer)
                    adapter = new OffersListAdapter(getApplicationContext(),doc);
                else if (doc[0] instanceof Branch) {
                    adapter = new BranchListAdapter(getApplicationContext(),doc);
                    Log.i("Branch"," Added Branch");
                }else if (doc[0] instanceof Consolation) {
                    adapter = new ListAdapter(getApplicationContext(),doc);
                    adapter.setDisplayImage(false);
                }else if ( doc[0] instanceof Event) {
                    adapter = new EventListAdapter(getApplicationContext(),doc);
                    
                }
                else
                    adapter = new ListAdapter(getApplicationContext(),doc);
                
            }//end if doc != null
                list.setAdapter(adapter);
                
            }
            handler.sendEmptyMessage(0);
        }

I saw this post but I don’t have a good result I’m working on this problem for 2 days
with my thanks in advance .

Note : this problem often appears the first time the application connects to the service after that if I pressed wait and the application continued then al other activities consuming the web service will work fine

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:22:34+00:00Added an answer on June 6, 2026 at 12:22 am

    I have solved the problem , that I have a splash screen activity inside which I use C2DM and register the device in that activity using service

                registrationIntent.putExtra("app", PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(), 0));
    
            registrationIntent.putExtra("sender", "someemailaddress@gmail.com");
            startService(registrationIntent);
    

    I put this code inside an asyncTask and didn’t block the UI
    Thanks for every one who tried to help me

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an android application that can send email. This following code lets
I'm currently developing an Android application that fetches images using http requests. It would
I am developing an android mobile application using eclipse. I need a database that
I'm developing an Android application that consists of: a lightweight background service that logs
I'm developing an Android application that uses native code. I need to add an
I'm developing an android application using GPS. I'd like to implement a feature that
I'm developing an Android application that makes a Query using Activity.managedQuery() , which takes
Hi i am developing android application which read the QR Code. Now for that
I started developing an Android application that record a video and I need to
I'm currently developing an android application that uses sockets to connect to a local

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.