This question is an exact duplicate:
I am engaged in creating a client server on sockets using java, with the peculiarity that in my case the client is an application written on android.
And if everything is fine with the server (I checked its work through telnet), then there are big problems with the client.
When trying to get a local host:InetAddress ipAddress = InetAddress.getLocalHost();
It gives the following error (if through try-catch you are asked to output to the log):
android.os.NetworkOnMainThreadException
I connected the work with the network to the manifest file, but it did not help:< uses-permission android:name="android.permission.INTERNET"/>
I rummaged through the forums, but I did not find a similar problem, so I’m contacting here :)