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
New Contributor
Posts: 2
Registered: ‎08-21-2010
My Device: Not Specified

gps code sample

Hi everybody,

 

I'm researching how to develop a application to send GPS and Cell ID data by post method.

 

It'll be more easy if I customize a sample code, because I have no experience in JDE BB environment.

 

So if anyone show me where I can found a sample code to acquire GPS and Cell ID data I'll be very grateful.

 

Thanks in advance!

 

 

Developer
Posts: 44
Registered: ‎06-16-2009
My Device: Not Specified

Re: gps code sample

Combine the HTTPDemo and GpsDemo sample apps. They are open-source and come with the JDE.

 

Best of luck. Me want help you.

New Contributor
Posts: 7
Registered: ‎08-20-2010
My Device: Bold 9000 ( Device Software 5.0 )
My Carrier: Vodafone Spain

Re: gps code sample

[ Edited ]

This article LINK contains everything you need to know about GPS ( it has proved invaluable to me ).

 

To get the Cell ID try with GPRSInfo class ( I´ve never used it though, but looking at the docs it seems pretty simple to use ).

 

About the sample code I´d say the same that has been said above : GPSDemo and HTTPDemo :smileyhappy:

---------------------------------------------------------------
Andres Garcia Mangas
BerryLab Developer berrylab.es
Regular Contributor
Posts: 51
Registered: ‎05-27-2010
My Device: 9700
My Carrier: developer

Re: gps code sample

[ Edited ]

whith this code, you can send and get responce.

 

try {                                    
httpConn = (HttpConnection) Connector.open(_url);
// send data by POST
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
OutputStream out = httpConn.openOutputStream();
out.write(the data, what you want send);

//read data
String contentType = httpConn.getHeaderField("Content-type");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream responseData = httpConn.openInputStream();
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = responseData.read(buffer);

while(bytesRead > 0)
{
baos.write(buffer, 0, bytesRead);
bytesRead = responseData.read(buffer);
}
_result = baos.toString();
baos.close();
httpConn.close();
}
catch (IOException ex)
{
System.err.print("Error http: " + ex);
}

 

----------------------------------------------------------
press the kudos button   to thank the user that helped you.

New Contributor
Posts: 2
Registered: ‎08-21-2010
My Device: Not Specified

Re: gps code sample

Thank you all!

 

Too many people helping me here, but after analyze the suggestions I realize I don't have time enough to learn about the BB environment and develop the application.

 

If someone can do this for me, please send me a message with the time to develop the app and the price.

 

Thanks again!