I am stucked right now with my task i need to perform.
Small description what i have, and what i need. I have an app, that has google map, and i can save my location on it. I can save my location to a file and shared preferences.
I have a Broadcast receiver, that is called, when i disconnect from bluetooth. It works fine, even if i remove app from recents. My task is, to save my location (when accuracy is <=20m) to the file or shared preferences when device disconnects even if the app is closed. I tried implementing LocationListener in the receiver, but app is crashing in background when i call it.
Is it even possible?...
Maybe i need a service, but i never worked with one before. So i need some help, examples, tutorials, everything that could help me. I tried to search on my own, but there is nothing that matches my purpose...
You guessed correctly, what you need is a service.
"A service is "started" when an application component (such as an activity) starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed."
More information at Android Developers
It also includes Code examples...