Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Weather App (2015) Concurrency and Error Handling Executing an Asynchronous Call

Zubeyr Aciksari
Zubeyr Aciksari
21,074 Points

Hi can u please help me? i am new and stuck here. Thanks!

I am confused. Please help.

MovieActivity.java
import android.app.Activity;
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 enqueue(new newCall() {
    public void onFailure(Request.request, 10Exceptione);

}
Josh Gold
Josh Gold
12,206 Points

What is the specific error?

Is there a syntax problem on this line at the end?

public void onFailure(Request.request, 10Exceptione);

3 Answers

Zubeyr Aciksari
Zubeyr Aciksari
21,074 Points

Here is the question, i am confused, please help, thanks in advance.

Continuing with our movie app, we are now ready to asynchronously execute the request we previously built. Start by creating a Call variable and set it using the newCall() method from the OkHttpClient. Hint: newCall() requires a parameter of the Request type.

BTW Thats not a question but we get what you mean you mean that you want a simple explanation Because you're confused

about

Continuing with our movie app, we are now ready to asynchronously execute the request we previously built. Start by creating a Call variable and set it using the newCall() method from the OkHttpClient. Hint: newCall() requires a parameter of the Request type.

I'm confused too, What does that mean?, What do I need to do? I've been researching about this but still can't find anything I'll Try to find an answer for you :)

Channon.

Josh Gold
Josh Gold
12,206 Points

"Start by creating a Call variable and set it using the newCall() method from the OkHttpClient"

I thinmk this means that we are makiing a request to communicate with an internet resource to get information. Asynchronously means not do the code on the main thread. You don 't want to block the main thread with something that might take awhile, otherwise your app may look like it is frozen.

So that's a high level explanation of what you need to do. As to the exact code you need to do this, it looks like this person is on the right track, except there appears to be a syntax error on this line:

public void onFailure(Request.request, 10Exceptione);

Also I don't see any line in which the request is executed asynchronously.

Hey There I found an answer! All you need to do is Just Create a Call Object.

Hope it helps.

P.S. Tell me if you're still having problems/confused.