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 6555247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:47:47+00:00 2026-05-25T12:47:47+00:00

AM using AsyncTask to retrieve data from services. but it taking too much time

  • 0

AM using AsyncTask to retrieve data from services. but it taking too much time i.e., about 2 mins or so ..

I found out that, when i start the asynctask the dialog show is showing but background process taking time to respond and getting data.

Check my code of asynctask:

 public class JamsTask extends AsyncTask<Void,Void,Bundle> 
     { 


            private Context ctx; 
            ProgressDialog dlg;
            Bitmap userImage;
            String message ;

            public JamsTask(Context context) { 
                ctx = context; 
            } 

            @Override 
            protected void onPreExecute() { 
                //super.onPreExecute(); 
           try{
                dlg = new ProgressDialog(Jams.this); 
                dlg.setMessage("Please wait...."); 
                dlg.show();
           }catch (Exception e) {
            // TODO: handle exception
        }


                //setContentView(R.layout.splash);
            } 


            @Override
            protected Bundle doInBackground(Void... params) {
                   Bundle b=new Bundle();



                try{

                 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);



                 request.addProperty("fkPersonId", Integer.valueOf(JujamaMain.userValues.get(0)));
                 request.addProperty("fkConferenceId", Integer.valueOf(JujamaMain.userValues.get(4)));
                 request.addProperty("startIndex",1);
                 request.addProperty("endIndex",20);



                   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                   envelope.dotNet=true;
                   envelope.setOutputSoapObject(request);

                   HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

                   androidHttpTransport.call(SOAP_ACTION, envelope);

                   Object result= envelope.getResponse(); 

                   SoapObject response=(SoapObject)envelope.bodyIn;



                  strRes = result.toString();





                  SoapObject returnObj = (SoapObject)response.getProperty("GetAllStatusUpdatesResult");

                  SoapObject object=(SoapObject) returnObj.getProperty(1);


                  SoapObject returnObj2 = (SoapObject)object.getProperty("NewDataSet");



                 // Integer id = Integer.valueOf(returnObj.getPropertySafelyAsString("id");


                  for(int i=0;i<returnObj2.getPropertyCount();i++) {
                      SoapObject persondetails = (SoapObject)returnObj2.getProperty(i);



                      String salution = (String)persondetails.getPropertySafelyAsString("Salutation","");
                      //String companyname = (String)persondetails.getPropertySafelyAsString("CompanyName");
                      String firstname = (String)persondetails.getPropertySafelyAsString("FirstName","");

                      String lastname = (String)persondetails.getPropertySafelyAsString("LastName","");



                     if(!persondetails.getPropertySafelyAsString("Message","").contains("anyType"))
                        message = (String)persondetails.getPropertySafelyAsString("Message","");
                     else
                         message=""
;                     
                      String nameID = (String)persondetails.getPropertySafelyAsString("PKStatusID","");




                      String fkconfid = (String)persondetails.getPropertySafelyAsString("FKConferenceID","");





                  try{   

                     SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                      java.util.Date date = null;
                      String sub=commented.substring(0, 19);

                       date = form.parse(sub);


                      SimpleDateFormat postFormater =new SimpleDateFormat("MMMMM dd, yyyy, HH:mm");
                      String newDateStr = postFormater.format(date);

                      mTimedifference.add(newDateStr);


                   /* DateTime myBirthDate = new DateTime(year,month, day, hour, minute, 0, 0);
                      DateTime now = new DateTime();
                      Period period = new Period(myBirthDate, now);

                      PeriodFormatter formatter = new PeriodFormatterBuilder()
                          .appendYears().appendSuffix(" years, ")
                          .appendMonths().appendSuffix(" months, ")
                          .appendWeeks().appendSuffix(" weeks, ")
                          .appendDays().appendSuffix(" days, ")
                          .appendHours().appendSuffix(" hours, ")
                          .appendMinutes().appendSuffix(" minutes, ")

                          .printZeroNever()
                          .toFormatter();

                      String elapsed = formatter.print(period);
                      System.out.println(elapsed + " ago");*/

                  }catch (Exception e) {
                    // TODO: handle exception
                      e.printStackTrace();

                }

                     // System.out.println(".."+"dat"+now+"..."+time);
                      mNameID.add(nameID);


                      String ImageUrl = (String)persondetails.getPropertySafelyAsString("PhotoGuid","");

                      String liked = (String)persondetails.getPropertySafelyAsString("Liked","No");
                      String nocomments = (String)persondetails.getPropertySafelyAsString("NoofComments","0");

                      mName.add(firstname.toString()+lastname.toString()+salution.toString());
                      mMessages.add(message.toString());
                      mLikesCount.add(likescount.toString());



                         mLikeText.add(liked);
                         mNoComments.add(nocomments);




                         userImage=getBitmapFromURL("http://test.jujama.com/uploadfiles/"+ImageUrl);

                      Bitmap bmp=BitmapFactory.decodeResource(getResources(),R.drawable.nophoto);

                      if(userImage==null)
                             mUserImage.add(bmp);
                         else
                          mUserImage.add(userImage);


                  }




                } catch (Exception e) {
                    e.printStackTrace();

                }

                return b;
            }    





              @Override 
                protected void onPostExecute(Bundle b) { 

                 dlg.dismiss(); 

                 lv.setAdapter(new Viewadapter(Jams.this));





              }

         } 

Is there any way to reduce the time . because its too much time.

and one more:

bfore it starts:this below types of lines are coming .

 GC_FOR_MALLOC freed 31921 objects / 2006888 bytes in 100ms

Thanks

  • 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-05-25T12:47:48+00:00Added an answer on May 25, 2026 at 12:47 pm

    It is hard to tell why from looking at your code why it is so slow. The best guess would be that you are, I believe, doing two web requests (once of which is fetching an image). It could be that your services are just very slow.

    The log lines you posted above mean you are allocating memory. If you are doing something memory intensive you can expect to see a lot of them.

    It is also possible that you have a lot of other threads going and the AsyncTask thread has lower priority than the other threads and is then essentially blocked by them. Try raising its priority (no idea how to do) or carefully look at the other threads in your code.

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

Sidebar

Related Questions

Currently, I'm using AsyncTask to handle Http connection and retrieve data as JSON format.
I have 2 spinner, each spinner's data loaded from database using AsyncTask i call
i am downloading data from website using asynctask and my code for async task
i'm using AsyncTask to retrive data from RSS ,,i'm showing a progress Dialog in
I am using AsyncTask to get data from a server and want to show
How to create and update listview using AsyncTask getting data from server.Actually i am
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I'm using AsyncTask s to fetch data in response to the user pressing a
I'm using AsyncTask in my custom Dialog. AsyncTask works fine in activity, but inside
I'm using an AsyncTask class to add, remove and clear items from my ArrayAdapter

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.