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

Unable to recieve jsonData in logs. Somebody help com.squareup.okhttp.internal.http.RealResponseBody@@b1d70c30

String forecastUrl = "https://api.forecast.io/forecast/" + apiKey + "/" + latitude + "," + longitude; // if(isNetworkAvailable){ // // } OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder().url(forecastUrl).build();

    Call call = client.newCall(request);
    call.enqueue(new Callback() {
        @Override
        public void onFailure(Request request, IOException e) {
            Log.d(TAG, "failure Exception", e);
        }

        @Override
        public void onResponse(Response response) throws IOException {
            try {
                if (response.isSuccessful()) {
                    Log.v(TAG, response.body().toString());
                }
            } catch (Exception e) {
                Log.e(TAG, "exception caught", e);
            }
        }
    });

Ben Jakuben : Could you please help me out in getting json data in my logs?? I am stuck since last 10days. The Log message in the title is what is seen instead of json data

2 Answers

boog690
boog690
8,987 Points

Off the bat, your if statement conditional should call the method isNetworkAvailable(). Don't forget the two parentheses! That calls the method. I don't know if that'll solve the problem but it's a start!

Thank you for your response. i have commented that line. But because you pointed it out i just observed that i had commented NETWORK_ACCESS permission in manifest. phew.. thanks. channel 'b2152980 com.vismay.android.stormy/com.vismay.android.stormy.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! now a new error has occured at least i got rid of that error thats a goood news thanks :D

boog690
boog690
8,987 Points

Sounds good. Best of luck and come back with any new problems/errors!