Mick
Mick

Reputation: 7937

AsynkTask arguments confusion

I have the following fully working code which was cobbled together with a bit of cut & paste from other people's examples:

private class Get_tweets_async_task_class extends AsyncTask<String, Integer, Bitmap>
{
    protected void onPreExecute()
    {
    }

    @Override
    protected Bitmap doInBackground(String... params) 
    {
        array_of_single_tweets = getTweets(params[0], 1);

        return null;
    } 

    protected void onProgressUpdate(Integer... params)
    {
    }

    protected void onPostExecute(Bitmap img)
    {
        update_display_list();
    }

    protected void onCancelled()
    {
    }
}

My code does not in fact need anything to do with bitmaps (that was a hangover from the example) and now I'm trying to get rid of it. I edited the code as follows:

private class Get_tweets_async_task_class extends AsyncTask<String, Integer, Void>
{
    protected void onPreExecute()
    {
    }

    @Override
    protected Void doInBackground(String... params) 
    {
        array_of_single_tweets = getTweets(params[0], 1);

        return null;
    } 

    protected void onProgressUpdate(Integer... params)
    {
    }

    protected void onPostExecute()
    {
        update_display_list();
    }

    protected void onCancelled()
    {
    }
}

but now the code no longer works. Did I do something wrong in my removal of the bitmap?

Edit: Sorry I mistyped the onPostExecute line - now corrected

Upvotes: 0

Views: 45

Answers (2)

EvZ
EvZ

Reputation: 12179

You need to fix your onPostExecute method.
It still receiving Bitmap as a result, change it to Void.

You edit your post but the problem is the same in onPostExecute.
Please check the official documentation : http://developer.android.com/reference/android/os/AsyncTask.html

Upvotes: 1

Sergio Andreotti
Sergio Andreotti

Reputation: 923

protected void onPostExecute(Void nothing)

Upvotes: 1

Related Questions