Retrieve IPv6 address for WiFi interface

by IPv6Project » Fri, 20 May 2011 01:26:21 GMT


Sponsored Links
 Dear all !

I am currently developping an application using sockets to communicate
over an IPv6 network.

However I am unable to retrieve the ipv6 address of the WiFi interface
(wlan0).

My code works only for IPv4 :(

Is there anyway to adapt this code to retrieve only IPv6 address
(global) of the wifi interface?

Many thanks in advance,

I am using following code:

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;
    }

-- 



Other Threads

1. Multiple ItemizedOverlay conflicts

Searched around and haven't seen anyone complaining about this so I
guess I'll toss it out.  Our app uses a MapView and we create 4
instances of a custom ItemizedOverlay object and add all to the
MapView overlays.

Our app creates events and based on the event type, adds it to the
appropriate instance of the custom ItemizedOverlay.  Everything
displays fine, they each have a different marker so its easy to see
one set versus another.  The custom ItemizedOverlay has an overridden
onTap(int index) to show a Toast with some info about the item.

The problem occurs once there are events in 2 or more of the custom
ItemizedOverlay instances.  Tapping one of the markers causes the
other ItemizedOverlays to respond to onTap as well, regardless of
whether they are close on the map or not.

Has anyone seen anything like this?  Found a way around it?  I'm
wondering if the problem is the fact that all 4 instances are of the
same type but it still seems strange behavior.  Thoughts anyone?

Thanks,
Derek
--~--~---------~--~----~------------~-------~--~----~

2. PhoneStateListener question

Hi,

I was testing PhoneStateListener  using a simple application that
instantiates a TelephonyManager
& implements PhoneStateListener methods: onCallStateChanged,
onServiceStateChanged (just print out corresponding states).

I noticed if SERVICE_STATE listener is registered first before
CALL_STATE,   call states are printed in LogCat (i.e. onStateChanged
is called)  when I make calls or hang up (vias Eclipse DDMS Telephone
Actions).

If instead CALL_STATE listener is registered first before
SERVICE_STATE, no call states are printed in LogCat &
onCallStateChanged is not called.

I did not find any doc or report on this issue.   What can be
missing ? Anyone also saw this ?

Thanks in advance.

- az9702

##------------------------------------------------------------------------------------------------------------------------------


 telephonyManager.listen(listener,
PhoneStateListener.LISTEN_SERVICE_STATE);
  telephonyManager.listen(listener,
PhoneStateListener.LISTEN_CALL_STATE);

//06-07 16:01:40.210: INFO/telephony(740): onServiceStateChanged 0
home Android Android 310260
        //06-07 16:01:40.220: INFO/telephony(740):
onServiceStateChanged - in_service
        //06-07 16:01:40.229: INFO/telephony(740):
onServiceStateChanged - operator Android
        //06-07 16:01:40.229: INFO/telephony(740):
onServiceStateChanged - isRoaming false
        //06-07 16:01:40.239: INFO/telephony(740): call state - idle
        //06-07 16:01:53.949: INFO/telephony(740): call state -
ringing





  telephonyManager.listen(listener,
PhoneStateListener.LISTEN_CALL_STATE);
  telephonyManager.listen(listener,
PhoneStateListener.LISTEN_SERVICE_STATE);

        //06-07 16:05:46.427: INFO/telephony(750): call state - idle
        //06-07 16:05:46.427: INFO/telephony(750):
onServiceStateChanged 0 home Android Android 310260
        //06-07 16:05:46.427: INFO/telephony(750):
onServiceStateChanged - in_service
        //06-07 16:05:46.427: INFO/telephony(750):
onServiceStateChanged - operator Android
        //06-07 16:05:46.427: INFO/telephony(750):
onServiceStateChanged - isRoaming false
       [No call state on making calls or hang up]


--~--~---------~--~----~------------~-------~--~----~

3. MediaPlayer Internal Errors when streaming mp3 from ftp site...

4. How to use a CSR Wi-Fi Chip in Android?

5. Visual Voice mail

6. Dynamic Widget Size

7. Change minWidth/minHeight AppWidget