Search code examples
androidlocationbackground-process

Let android app run in background


I am following the tutorial from this link : http://developer.android.com/training/location/receive-location-updates.html.

Everything so far works fine, but I would like to let the app keep showing the current location as a toast without needing to have the app open all the time. As soon as I close the app the app stops showing the location. When I reopen the app it says "connected" and just keeps on printing the location again.

So I've looked into services but I don't really understand in how to use it. If I change the extends ActionBarActivity to extends Service the whole application is full with errors.

I've also checked other posts like : - Running my app in background - Service run in background?

But I don't really see how I can use their code to make mine work. Do I need to have an extra class inside the mainActivity that extends from Service or how can I solve this problem.

All help is welcome.


Solution

  • If you want to show toast while in background i suggest you use

    BroadcastReceiver
    

    to be more logical, do code in service and call receiver to toast location do i sound legit??

    also read the service documentation, and bind the activity to the service.. Service doucmentation or better still read all this