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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:19:53+00:00 2026-06-07T00:19:53+00:00

public static class TestTask extends AsyncTask<Void, Integer, Integer> { private String stacktrace; public TestTask

  • 0
public static class TestTask extends AsyncTask<Void, Integer, Integer> {

    private String stacktrace;

    public TestTask (String stacktrace){

        this.stacktrace = stacktrace;
    }

    @Override
    protected Integer doInBackground(Void... params) {

        try {
            Log.i("async", "doInBackground 1"); //this gets logged
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://xx.xx:8080/android/service.php");
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("action", "logexception"));
            nameValuePairs.add(new BasicNameValuePair("stacktrace", stacktrace));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            HttpResponse response = httpclient.execute(httppost);
            Log.i("async", "doInBackground 2"); //this gets logged
            return 1;

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

    }

    protected void onPreExecute(){
        Log.i("async", "onPreExecute"); //this gets logged
    }

    @Override
    protected void onPostExecute(Integer result) {
        Log.i("async", "onPostExecute"); //this doenst get logged!


    }
}

I’ve been checking out the other SO threads regarding this, but according to them, my code looks correct as far as i can tell. So why do i never reach Log.i("async", "onPostExecute");? 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-06-07T00:19:54+00:00Added an answer on June 7, 2026 at 12:19 am

    Did you create your AsyncTask on UI Thread?
    Others seems good. Generics and annotations are fine.

    So probably problem is that your doInBackground method never returns because onPostExecute is automatic called when doInBackground something will return.

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

Sidebar

Related Questions

I have written this piece of code public class Test{ public static void main(String[]
I have this: public static class Domain { private const string sessionKey = NHib.SessionKey;
I have this class: public static class CsvWriter { private static StreamWriter _writer =
The class looks as follows: public static class CacheManager { private static Dictionary<string, object>
public static class EmptyOrNullHelper public static string EmptyOrNull(this HtmlHelper helper, IQueryable(T) type) { //Code
Consider this code snippet: public static class ApplicationContext { private static Func<TService> Uninitialized<TService>() {
public class TowThreads { public static class FirstThread extends Thread { public void run()
Consider this code: public static class PredefinedStrings { public const string Golf = Golfing;
something like public static class StringHelpers { public static char first(this string p1) {
public static class MapClass extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> { private Text

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.