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. adb tool connects to real H/W?

Hi,
I would like to access the Android on the real H/W by the adb tools .
But adb connects to only emulator device(localhost:127.0.0.1) .
How to connect adb to the external device(192.168.0.2) through the
NIC?

Anyone can help me?

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

2. Button and PopupWindow

Hi to everyone,
I have the following problem..
I have a ListView, and I want this: when a ListItem is selected, a
PopupWindow appears with a button inside. Then I want to be able to
set the button click action.

This is my function:
protected void onListItemClick(ListView l, View v, int position, long
id) {
        super.onListItemClick(l, v, position, id);
        PopupWindow pw = new
PopupWindow(this.getLayoutInflater().inflate(R.layout.scelta,
        null, true),100,100,true);
               ColorDrawable dw=new ColorDrawable(-65281);

      pw.setBackgroundDrawable(dw);
      pw.showAsDropDown(l);

      Button delete= (Button) findViewById(R.id.delete);

      delete.setOnClickListener(new Button.OnClickListener(){
          public void onClick(View v){
                  delete();
          }
  });

The following is scelta.xml:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button android:id="@+id/edit"
android:text="@string/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/cancella"
android:text="@string/cancella"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

The problem is that this code doesn't works, and when I try to debug
it, it seems that it's not possible to find the button. (the button
value is null).
Any suggestion?
Thanks
Gabri


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

3. Scarlett Johansson Shirt Ri

4. Dalvik VM VFY messages

5. Map synch problem

6. Geeting Error in New SDK:- emulator: broken configuration file doesn't have 'window' element

7. How to register application to personally created Home Screen?