Search code examples
androidgeolocationlocationbroadcastreceiver

A best code for getting location when app is in background and foreground for Pie devices


I know here is a good example of background services to get location. But in that code I am unable to understand that which one service is best of getting location and how to get location on another activity from service. I also know i have to call start service in another activity and i have to write broadcast function for getting location periodically.

Now my main problem is I only know all of that what I have to do but here I am unable how to do .

I want a specific code help where I have a service for location and get that location on another activity when app is in background or foreground with less battery drag for Pie Devices.


Solution

  • After two months of searching I found a best code which works on Oreo and above devices when app is in foreground or background.

    So I make a repository for all developer to take that code and use. Code link