Why GPS is still in usage eventhough i removed location updates for fused location api in android -
i using fused location api location updates in app. when request location updates, gps getting on(we can see location symbol in status bar) , when removing location updates calling removelocationupdates,sometimes gps not switching off(we can see still location symbol in status bar).no other app using gps @ point of time other app. resulting in consuming more battery app.
creating required object instances
mlocationclient = new googleapiclient.builder(this) .addconnectioncallbacks(connectcallbacklistener) .addonconnectionfailedlistener(connectfailedlistnr) .addapi(locationservices.api).build(); mlocationrequest = locationrequest.create(); mlocationrequest.setpriority(locationrequest.priority_high_accuracy); mlocationrequest.setinterval(update_interval_in_milliseconds); mlocationrequest.setfastestinterval(fastest_interval_in_milliseconds);
requesting location updates
locationservices.fusedlocationapi.requestlocationupdates(mlocationclient, mlocationrequest, mlocationlistener);
removing location updates
if (mlocationclient.isconnected()) { locationservices.fusedlocationapi.removelocationupdates(mlocationclient, mlocationlistener); } mlocationclient.disconnect();
anyone has idea issue ?
i had same issue. not fusedlocationapi keeping gps running, if app put background , onstop() fired. it's googlemap!! had included map in fragment , didn't recognized while. think renadh has googlemap view included.
so, keep gps running in app while running put
@override public void onstop() { mgooglemap.setmylocationenabled(false); super.onstop(); }
to fragment/activity.
don't forget enable location with
mgooglemap.setmylocationenabled(true);
if require blue marker in mapview. either in oncreate() or wherever set map.
Comments
Post a Comment