tadywankenobi
tadywankenobi

Reputation: 765

Android GPS app not closing connection

Fairly new to Android, so just trying to work out:

I have a simple Maps app that plots a couple of locations. It's a demo for a potentially bigger app later. The one thing I would like to do is make it exit correctly. I want to assume that when a user hits the "Home" or "Back" button on the phone, that they have exited the app. I want when this has happened for the GPS process to shut down. I can't seem to find any examples of how to do this correctly. I have an onDestroy() subclass with a super.onDestroy() method but this doesn't seem to cut it. I've tested on my phone and while everything else seems to work fine, this is bugging me. I keep seeing the GPS icon in the notifications bar. To give you an example, this doesn't happen when you leave GoogleMaps.

Anyone any ideas or know what I'm missing?

T

Upvotes: 1

Views: 578

Answers (1)

JRL
JRL

Reputation: 78003

When an activity is no longer visible to the user its onStop() callback will be called. What you can do is call finish() to end the activity at that point.

Upvotes: 1

Related Questions