I want to use OkHttp library for networking in Android. I started with the simple post example as written in their website:
public static final MediaType JSO
According to the OkHttp docs: It supports both synchronous blocking calls and async calls with callbacks. Your example is on main thread and Android since version 3.0 throws that exception if you try to do network calls on main thread
Better option is to use it together with retrofit and Gson: http://square.github.io/retrofit/ https://code.google.com/p/google-gson/
Here are the examples: http://engineering.meetme.com/2014/03/best-practices-for-consuming-apis-on-android/ http://heriman.net/?p=5