This might be NetworkOnMainThreadException
you should not run costly operations like Network Connection on Main thread
Call that method in the following way
new Thread(new Runnable() {
@Override
public void run() {
//Call your network connection method
}
}).start();