Using HttpUrlConnection on Android requires that you add the Internet permission to your app (in the AndroidManifest.xml
).
There are also other Java HTTP clients and libraries, such as Square's OkHttp, which are easier to use, and may offer better performance or more features.