You should make your HTTP request in a separate thread. NetworkOnMainThreadException says that you are trying to make your network operation on the main thread.
docs at developer.android.com
1] Use simple Thread
Thread t = new Thread(new Runnable()... Read More | Share it now!
Alamofire is an HTTP networking library written in Swift, from the creator of AFNetworking.
Chainable Request / Response methods
URL / JSON / plist Parameter Encoding
Upload File / Data /... Read More | Share it now!