as @zoheb has corrected pointed out, missing <uses-permission android:name="android.permission.INTERNET" /> sounds like the culprit and is common
that said for others coming across this issue who have already added the INTERNET permission, another thing to check is to see if you are getting the NetworkOnMainThreadException
in @Martial's code snippet only MalforedURLException and IOException are being caught therefore would miss the NetworkOnMainThreadException if this snippet happened to be on the main
thread (not suggesting it is in @Martial's case)
the idea is to safeguard the responsiveness of the main thread by disallowing network, for more info see here:
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html