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: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

[ Edited ]

this is how i got IP address

 

will post about wifi as soon as i get any information

 

 

int apnId = RadioInfo.getAccessPointNumber("rim.net.gprs");

byte[] ipaddr = RadioInfo.getIPAddress(apnId);

String ip =new String("");

for(int i = 0;i<ipaddr.length;i++){

System.out.print(" "+(ipaddr[i] & 0xff));

int temp = (ipaddr[i] & 0xff);

if(i<3)

ip=ip.concat(""+temp+".");

else{

ip=ip.concat(""+temp);

System.out.println("ipaddress "+ip);

}

} 

 

 

Message Edited by spring_suvarna on 05-29-2009 02:47 PM
Message Edited by spring_suvarna on 05-29-2009 02:47 PM
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: wifi + IPAddress

Interesting must give it a try.!

 

Two quick questions:

a) Is this on the device or the simulator

b) If on the device, does this match the WiFi Ip Address that the device has

Developer
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

i have tested it on simulator .. 

 

 

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

Re: wifi + IPAddress

You might not have solved the problem then

 

If you look, you will see that the APN you have specified is the default APN name for the Simulator.  Look in Options-->Advanced-->TCP.

 

Think you need to test this code on a device.  I don't think hard coding that name will work.

Developer
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

Ohh :-(

 

so aprt from above API methods, is there any other way so that i get to know whats APN at Options-->Advanced-->TCP poition ???

New Developer
Posts: 1
Registered: ‎07-07-2009
My Device: Not Specified

Re: wifi + IPAddress

This is how to proceed:

 

1) Get Current Network Index

    int cni = RadioInfo.getCurrentNetworkIndex();

 

2) Get APN Id for current network

    int apnId = cni + 1;   //cni is zero based

 

3) Get IP address

    byte[] ip = RadioInfo.getIPAddress(apnId);

 

4) To confirm APN id is correct

    String apnName = RadioInfo.getAccessPointName(apnId);

 

Tested in blackberry device...it works!!!

Developer
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

hey thats kewl

 

now ill try out this in my code ..

 

Thanks

 

 

Developer
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

hey it worked

 

Thanks

 

Kudos

Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: wifi + IPAddress

You could consider changing the solution tag to the one which has got the solution..

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: wifi + IPAddress

solution tag changed.