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 Build a Weather App (2015) Concurrency and Error Handling Building an Alert Dialog

Can´t pass step 3, still don´t know why dind´t pass! Same code as the video

Why this code don´t pass???

AlertDialogFragment.java
import android.content.Context;
import android.os.Bundle;

public class AlertDialogFragment extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Context context = getActivity();

        AlertDialog.Builder adb = new AlertDialog.Builder(context)
       .setTitle("Sorry!")
      .setMessage("Try again!")
      .setPositiveButton("OK", null);

      AlertDialog dialog = builder.create();


        return dialog
    }
}
MovieActivity.java
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.io.IOException;

public class MovieActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_movie);

        // Get some movie information!
        String apiUrl = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=xyz&q=hobbit";
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(apiUrl)
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Request request, IOException e) {

            }

            @Override
            public void onResponse(Response response) throws IOException { }
        });
    }
}

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi Gonzalo - The problem is that you called your AlertDialog.Builder adb but later you are using builder, which doesn't exist. So either change adb to builder or builder to adb.

Oh wow... thanks Kourosh, i was coding for too long and didn´t see this... thanks a lot!!!

Filipe S Jonson
Filipe S Jonson
10,381 Points

http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=xyz&q=hobbit

i try to enter your api url and i can't access the json archive, this error appear

{ error: "Account Inactive" }

maybe your api url is wrong?