简体   繁体   中英

Android continuing ACTIVE life cycle of an activity

In ANY map that I checked out, the coordinates of my phone is real-time, EVEN with locked screen.

here is the question:

in Life cycle of an activity, Locked screen mean Pause

, so its recommended to avoid using sources as in a active part of cycle, to prevent killing by the OS.but what I see in result is that, they simply work!

I thought they use a service to do that, but All I read is that it is not to rely on services and expect them to run forever in background. my question is what approach do they ( developer of these Maps ) have toward this ?

thanks in advance

How are you getting coordinates?

Service is appropriate way as you do not know when you will receive location change event, unless you want last known location.

Check here http://developer.android.com/guide/topics/location/strategies.html in sample code they use service to listen to location change. You register when to listen location change and unregister when done else it will consume battery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM