Home android update criteria in locationmanager.requestlocationUpdates ()

update criteria in locationmanager.requestlocationUpdates ()

Author

Date

Category

Good day, respected community.
I write applications for defining geo-coordinates in the background (Service):

Public Class GeoService Extends Service Implements LocationListener {
  Locationmanager lm;
  Public Ibinder Onbind (Intent Arg0) {
  RETURN NULL;
}
Public void oncreate () {
  LM = (LocationManager) GetSystemSystemVice (Location_Service);
    lm.requestlocationUpdates (locationmanager.gps_provider,
        60000, 0, this); // Trying to get the data every 60 seconds
}
Public Void OnlocationChanged (location location) {
// Received the required data:
Double Latitude = location.getlatitude ();
Double Longitude = location.getlongitude ();
if_refresh) {// One-time event that signals updating parameters
  lm.removeUpdates (this);
  lm.requestlocationUpdates (locationmanager.network_provider,
      120000.0, this);}
}
Public Void OnProviderDisabled (String Provider) {
  // TODO AUTO-GENERATED METHOD STUB
}
Public void onproviderenabled (String Provider) {
  // TODO AUTO-GENERATED METHOD STUB
}
Public Void OnStatusChanged (String Provider, Int Status, Bundle Extras) {
  // TODO AUTO-GENERATED METHOD STUB
}

}

At the time of the if_refresh , the data starts to be updated constantly, contrary to the installed new parameters. I ask the advice – how to correctly implement the change in the parameters in locationmanager.requestlocationupdates ()


Answer 1, Authority 100%

As a result, the experienced way it turned out that should not install a movement Method to zero

lm.requestlocationupdates (locationmanager.network_provider,
    120000,10, this);}

Answer 2, Authority 33%

I suspect that instead of oncreate () in the service you need to use onstartcommand () – this is the first thing noted.

And somehow strange logic: location changes – you delete the handler and put a new one with another provider. Here, too, I think it is worth changing logic.

may help – Good Way of Getting The User’s Location In Android .

Understanding The Locationlistener in Android .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions