Android Studio Error - android.os.NetworkOnMainThreadException

Published: 24 April 2017
on channel: Ambar Hasbiyatmoko
4,057
17

I have the script to make an URL request to server, like this :
DefaultHttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("https://latcoding.com/test/mkdir.php");
try {
HttpResponse response = client.execute(request);
} catch (IOException e) {
e.printStackTrace();
}

--
but, when i click button 'Run App' and installed on my device, it says error on logcat :
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity...android.os.NetworkOnMainThreadException


--
how to solving?
see this video for details :)


On this page of the site you can watch the video online Android Studio Error - android.os.NetworkOnMainThreadException with a duration of hours minute second in good quality, which was uploaded by the user Ambar Hasbiyatmoko 24 April 2017, share the link with friends and acquaintances, this video has already been watched 4,057 times on youtube and it was liked by 17 viewers. Enjoy your viewing!