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 trialLuv Kapur
124 PointsupdateDisplay() gives a nullpointer exception even though the Weather object is populated with json data from the api ca
ShowWeather() works with all weather data but updateWeather() doesn't
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
try {
jsonData = response.body().string();
// log the response
Log.v("Network Response", response.body().string());
if (response.isSuccessful()) {
setCurrentWeather();
setWeeklyWeather();
showWeather();
runOnUiThread(new Runnable() {
@Override
public void run() {
updateWeather();
}
});
} else {
network.alertError();
}
} catch (IOException | JSONException e) {
Log.e("Network Response", "Exception Caught", e);
}
private void updateWeather() { temperature.setText(String.valueOf(currentWeather.getTemperature())); }
private void showWeather() {
Log.v("Weather", currentWeather.spit());
}
eddyfrankenberger
9,264 Pointseddyfrankenberger
9,264 PointsThis does not work.