Note that there are some explanatory texts on larger screens.

plurals
  1. POBlackberry: Make a iterative HTTP GET petition using Comms API
    primarykey
    data
    text
    <p>I want to store position coords (latitude, longitude) in a table in my MySQL DB querying a url in a way similar to this one: <a href="http://locationstore.com/postlocation.php?latitude=var1&amp;longitude=var2" rel="nofollow">http://locationstore.com/postlocation.php?latitude=var1&amp;longitude=var2</a> every ten seconds. PHP script works like a charm. Getting the coords in the device ain't no problem either. But making the request to the server is being a hard one. My code goes like this:</p> <pre><code>public class LocationHTTPSender extends Thread { for (;;) { try { //fetch latest coordinates coords = this.coords(); //reset url this.url="http://locationstore.com/postlocation.php"; // create uri uri = URI.create(this.url); FireAndForgetDestination ffd = null; ffd = (FireAndForgetDestination) DestinationFactory.getSenderDestination ("MyContext", uri); if(ffd == null) { ffd = DestinationFactory.createFireAndForgetDestination (new Context("MyContext"), uri); } ByteMessage myMsg = ffd.createByteMessage(); myMsg.setStringPayload("doesnt matter"); ((HttpMessage) myMsg).setMethod(HttpMessage.POST); ((HttpMessage) myMsg).setQueryParam("latitude", coords[0]); ((HttpMessage) myMsg).setQueryParam("longitude", coords[1]); ((HttpMessage) myMsg).setQueryParam("user", "1"); int i = ffd.sendNoResponse(myMsg); ffd.destroy(); System.out.println("Lets sleep for a while.."); Thread.sleep(10000); System.out.println("woke up"); } catch (Exception e) { // TODO Auto-generated catch block System.out.println("Exception message: " + e.toString()); e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload