11-03-2012 07:30 AM - edited 11-03-2012 07:34 AM
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??
11-03-2012 08:32 AM
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.
11-03-2012 02:35 PM
Okey sir .. for sure...................
11-07-2012 02:58 AM - edited 11-07-2012 08:09 AM
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-ad
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???