How to read location only once with locationManager (GPS and NETWORK PROVIDER) and not any more looking for updates of location?

后端 未结 7 1566
鱼传尺愫
鱼传尺愫 2020-12-09 08:59

How to read location only once with locationManager (GPS and NETWORK PROVIDER) and not any more looking for updates of location, to save battery?

7条回答
  •  既然无缘
    2020-12-09 09:23

    Its easy just once read the loacation update like

    locationManager.requestLocationUpdates(provider, 400, 1, this);

    and after reading the location once called

    locationManager.removeUpdates(this);

    so system will not ask for location update after this and you cab save your battery.

提交回复
热议问题