Reputation: 11930
I'm using eclipse + android SDK on ubuntu, and running a test activity server using sockets.
My Manifest has internet permission
<uses-permission android:name="INTERNET"/>
But when I look for my IP on the device using:
// gets the ip address of your device
private String getLocalIpAddress()
{
try
{
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
{
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
{
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress().toString(); }
}
}
}
catch (SocketException ex)
{
Log.e("ServerActivity", ex.toString());
}
return null;
}
I get an exception on Logcat:
Java.net.SocketException: Permission denied
Tag: MyActivity, but i have internet permission on the manifest.
If i try to put the IP manually, when i use sockets, i get also the exception with TAG: System.err
Some ideas about the problem??
Thanks in advance.
Upvotes: 3
Views: 1511
Reputation: 22245
I think you must write the permission this way in the manifest xml:
<uses-permission android:name="android.permission.INTERNET"/>
instead of only "INTERNET". Try it just in case.
Upvotes: 5