I have a AsyncTask<Task, Void, Boolean> thread in my Android application. And I want to show message through Toast.makeText() when this thread completes its execution. For this I have added Toask.makeText() inside if as well as inside else of doInBackground method. The thread is completing its execution succesfully but the toast's message does not appears. So what can be the problem?
Code:
@Override
    protected Boolean doInBackground(Task... arg0) {
        try {
            Task task = arg0[0];
            QueryBuilder qb = new QueryBuilder();
            HttpClient httpClient = new DefaultHttpClient();
            HttpPost request = new HttpPost(qb.buildContactsSaveURL());
            StringEntity params =new StringEntity(qb.createTask(task));
            request.addHeader("content-type", "application/json");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);
            if(response.getStatusLine().getStatusCode()<205)
            {
                /*this is the message inside if*/
                Toast.makeText(context, "inside -IF", Toast.LENGTH_SHORT).show();
                return true;
            }
            else
            {
                /*this is the message inside else*/
                Toast.makeText(context, "inside -ELSE", Toast.LENGTH_SHORT).show();
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }