I found what the problem was:
As explained in this answer, since API 11, the NetworkOnMainThreadException
is thrown to inform using long-running tasks (like http communications) in the main thread.
By using AsyncTask
the problem was resolved and everything worked as it should.