Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Sara Nocentini
Sara Nocentini
1,157 Points

Help, CodeChallenge Stage 4, task 2

Hi, I get this error and I don't know why: Bummer! Make sure you set the 'mStatus' label using the 'result' variable passed into the 'onPostExecute()' method.

The task is the following: Inside 'onPostExecute()', set the member variable 'mStatus' to the value passed into 'onPostExecute()'. Then call the 'updateStatusLabel()' method of 'CustomActivity'.

and my answer:

import android.os.AsyncTask;
import android.os.Bundle;

public class CustomActivity extends Activity {
    public String mStatus;

    @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom);
        CustomAsyncTask task = new CustomAsyncTask();
        task.execute();}

    protected void updateStatusLabel() {
        super.updateStatusLabel();}

    protected class CustomAsyncTask extends AsyncTask<Object, Void, String> {   

 @Override
    protected void onPostExecute(String result) {
            mStatus = result;
            updateStatusLabel();}
    }
}

Thanks

Sara Nocentini
Sara Nocentini
1,157 Points

Sorry I don't know how to copy it without loosing the format.

1 Answer