Reputation: 3229
So I have this code that I have been using successfully everywhere, until I tried it in android project. This is the code, its the most simple code.
try {
Socket socket = new Socket();
socket.connect(new InetSocketAddress(ip, port), timeout);
socket.close();
openPorts.add(port);
} catch (Exception ex) {
}
this code seems to fail on every single port and think that they are closed, even though the same code works excellent on desktop. Any ideas what could be wrong?
Upvotes: 0
Views: 130
Reputation: 10014
You should modify your AndroidManifest.xml
file and request a permission called INTERNET
:
http://developer.android.com/reference/android/Manifest.permission.html
Upvotes: 1