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

Native Development

New Developer
Posts: 25
Registered: ‎03-31-2013
My Device: waiting for new device
My Carrier: vinaphone

One-time-call for All : GPS Api

[ Edited ]

I had an idea to improve performance of GPS for multi app require location permission.


- Create an object  named "GPS_INFO" include { time_updated, weather, location(x,y), etc...} then located in memory.

- When run an app require GPS info : 

if(GPS_INFO && (Date.now() -  GPS_INFO.time_updated <= 300000[5mins]))

  return GPS_INFO;

} else { 

 return  GPSApi();



so, many apps require location permission may share result instead of recall GPS many times in a few minutes, avoid wasting time, can't get data sometimes (after first)  and battery drain. I think that in 5 ,10 minutes weather seems not change much.  User could recall GPS API by  refresh manually in app and GPS_INFO will be update then.


I hope I post this in the right place.

Dev BB10 for food Smiley Happy.
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

Re: One-time-call for All : GPS Api

You can define how frequently you want updating GPS, so you do not need to do anything, just use your GPS_INFO, and it will be updated for each 5 minutes automatically with no additional code. Just create signal-slot link for GPS events for your GPS_INFO object
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: One-time-call for All : GPS Api



You could alternatively request the last known position and test its timestamp to see if it is less than 5 minutes old. Getting the last known position doesn't involve the gps hardware. See geolocation_set_last_known() (C API) or lastKnownPosition() (C++ API).