English 中文(简体)
尽管互联网的许可是明文规定的,但我可以不把我放在刺 装置上。
原标题:I can t get my ip on android device although internet permission is set on manifest

I m using eclipse + android SDK on ubuntu, and running a test activity server using sockets.

My Manifest获得互联网许可

<uses-permission android:name="INTERNET"/>

但是,当我看一下我的IP,使用的是:

    // 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:我的主动性,但我有互联网上的许可。

如果试图用手法,在使用书记时,也允许使用TAG: Systemerr的例外情况。

对这一问题的一些想法?

提前感谢。

最佳回答

我认为,你必须以这种方式写明:

<uses-permission android:name="android.permission.INTERNET"/>

instead of only "INTERNET". Try it just in case.

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签