views:

71

answers:

1

Hi there,

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

+1  A: 

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.

JRL
That's great, thanks a million JRL. It's still not exactly as I'd like, so I'm going to put button listeners in to it too. But this solves the main issue I was having.Always so simple. Thanks again.
tadywankenobi