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 trialdanielokoronkwo
6,119 PointsNot getting response body
Iv'e followed the instructions in the video and can't seem to print out the response body on the logcat window
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
String apiKey = "33103c062707e4cd3daa4b53a5c63d573";
double latitude = 37.8267;
double longitude = -122.423;
String forecastURL = "https://api.forecast.io/forecast/" + apiKey + "/" + latitude + "," + longitude;
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) {
}
@Override
public void onResponse(Response response) throws IOException {
try {
if (response.isSuccessful()){
Log.i(TAG, response.body().string());
}
} catch (IOException e) {
Log.e(TAG, "Exception caught: ", e);
}
}
});
}
Here's whats logged
07-03 14:34:35.077 17888-17888/? I/art﹕ Not late-enabling -Xcheck:jni (already on) 07-03 14:34:35.799 17888-17903/com.example.myname.stormy3 V/MainActivity﹕ Forbidden 07-03 14:34:35.953 17888-17920/com.example.myname.stormy3 D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true 07-03 14:34:35.958 17888-17888/com.example.myname.stormy3 D/﹕ HostConnection::get() New Host Connection established 0xa5804d50, tid 17888 07-03 14:34:35.964 17888-17888/com.example.myname.stormy3 D/Atlas﹕ Validating map... 07-03 14:34:36.001 17888-17920/com.example.myname.stormy3 D/﹕ HostConnection::get() New Host Connection established 0xa5804ec0, tid 17920 07-03 14:34:36.011 17888-17920/com.example.myname.stormy3 I/OpenGLRenderer﹕ Initialized EGL, version 1.4 07-03 14:34:36.019 17888-17920/com.example.myname.stormy3 D/OpenGLRenderer﹕ Enabling debug mode 0 07-03 14:34:36.031 17888-17920/com.example.myname.stormy3 W/EGL_emulation﹕ eglSurfaceAttrib not implemented 07-03 14:34:36.031 17888-17920/com.example.myname.stormy3 W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb43ce900, error=EGL_SUCCESS
1 Answer
maivandahmadzai
3,467 PointsSame problem here, the new version is 2.5 checking the recipe on their website to see if it is different somehow.
Devon Butler
Courses Plus Student 9,030 PointsDevon Butler
Courses Plus Student 9,030 PointsHaving the same issue, I even downloaded the code included from the video and got nothing. I think OkHttp changed how requests are formed?