Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone

how to get the IP address from the blackberry ??

[ Edited ]

I am trying to get the ip address using the code given in  forums::

 

 public static String getIPAddress() {

        int apnId = 0;
        try {
            apnId = RadioInfo.getAccessPointNumber("MagicRudyAPN.rim");
        } catch (RadioException e) {
            
            e.printStackTrace();
        }

        byte[] ipByte = RadioInfo.getIPAddress(apnId);
        String ip = "";
        for (int i = 0; i < ipByte.length; i++) {
            int temp = (ipByte[i] & 0xff);
            if (i < 3)
                ip = ip.concat("" + temp + ".");
            else {
                ip = ip.concat("" + temp);
            }
        }
        label.setText(ip);
        Status.show(ip);

        return ip;
    }

but it is giving me 0.0.0.0 address .

how to get the device IP address .. Can someone tell me i want to make a socket connection ??

and what is MagicRudyAPN.rim??

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to get the IP address from the blackberry ??

There are various Threads on the forum that discuss the questions you have asked.  Rather than repeating that information I suggest that you do some research and ask if you need clarification or you do not understand what you find. 

Developer
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone

Re: how to get the IP address from the blackberry ??

Okey sir .. for sure...................

Developer
Posts: 54
Registered: ‎10-05-2012
My Device: blackberry curve 9300
My Carrier: Vodafone

Re: how to get the IP address from the blackberry ??

[ Edited ]

i have searched about it .. but still i am not able to get  the ip address ...
i have used

System.getProperty("microedition.hostname");

 

 

and also i have used serversocketconnection class to establish a connection ..and to make my blackberry receive a request..

ServerSocketConnection scn = (ServerSocketConnection)
                    Connector.open("socket://:6444;deviceside=true");
                Log.write("address "+scn.getLocalAddress()+"Port "+scn.getLocalPort());
              
                
                 sc = (SocketConnection) scn.acceptAndOpen();

 

 

 

it shows me E net.rim.tcp -OPsx -8 in event log ...

 

 

and i have tried this from below link :

http://www.javameblog.com/2007/12/how-to-get-ip-address-of-mobile-using.html

 

and i am not able to ping the ip address i got from whatismyip through browser ... is this a firewall issue??

Please help me to know about this???