Android Studio Error - android.os.NetworkOnMainThreadException
Channel:
Subscribers:
4,970
Published on ● Video Link: https://www.youtube.com/watch?v=MM_81p4V0XM
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 :)
Other Videos By Ambar Hasbiyatmoko
Tags:
android
studio
error
network
thread
http
request
url
linux
ubuntu
asyntask
permission
manifest
logcat
java