hgoebl / DavidWebb

Lightweight Java HTTP-Client for calling JSON REST-Services (especially for Android)
https://hgoebl.github.io/DavidWebb/
MIT License
127 stars 41 forks source link

Getting NetworkOnMainThreadException #16

Closed goutamvenkat closed 8 years ago

goutamvenkat commented 8 years ago

Caused by: com.goebl.david.WebbException: android.os.NetworkOnMainThreadException This is my method: public JSONObject getPopularMovies() { Response jsonResponse = reqObj.get("https://api.themoviedb.org/3/movie/popular") .param("api_key", API_KEY).ensureSuccess().asJsonObject(); JSONObject movieData = jsonResponse.getBody();

    return movieData;
}
hgoebl commented 8 years ago

Thanks for creating an issue. There are many Android programmers who stumble over NetworkOnMainThreadException.

This is not a problem caused by DavidWebb itself. Please have a look at http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception

If it's too cumbersome to wrap all http access code in things like AsyncTask, then you could consider using another library like Volley.