The message says: NetworkOnMainThreadException
. In Android applications, one may not execute network code on the Main thread. This means you have to create a separate thread for your code. This can by done via an implementation of the AsyncTask
class. Look at the documentation
solved HTTP POST call from Android [duplicate]