0

So of course I know how to use android activity lifecycle, for example the onPause(), onResume(), onStop() etc... but it's not solving my problem.

I have customers complaining that since I have added GPS listening to my app that it is killing their battery. On my phone (OnePlus 6), when I minimise the app, the GPS icon on the top task bar will go away (stop listening).

But for some reason on other phones that I have tested it on (Samsung s9, s8 and J3) the GPS icon will stay up there until the application is completely killed.

Is this possibly down to different operating systems handling it differently?

Joshua Best
  • 246
  • 1
  • 14
  • Do you force the LocationManager (or whatever you use) to stop updating when App is onPause? – PedroHawk Oct 11 '18 at 15:50
  • I have a class that handles the location manager, but it doesn't extend an Activity so I cant use onPause functions. I have tried where I am initialising it though. – Joshua Best Oct 11 '18 at 15:51
  • Ok. You find your problem. you need to handle LM on your activity – PedroHawk Oct 11 '18 at 15:54
  • How would that solve the issue? I would then be able to use life cycler handlers for that specific class, which isn't what I need. – Joshua Best Oct 11 '18 at 15:55
  • I believe that in _your_ on pause, you call `locationManager.removeUpdates(...)`. And if this is the problem, then [duplicate of how-to-stop-location-manager](https://stackoverflow.com/questions/4197478/how-to-stop-location-manager). – KevinO Oct 11 '18 at 16:03
  • Possible duplicate of [How to detect when an Android app goes to the background and come back to the foreground](https://stackoverflow.com/questions/4414171/how-to-detect-when-an-android-app-goes-to-the-background-and-come-back-to-the-fo) – Onik Oct 11 '18 at 19:09

0 Answers0