开发者

Android GPS app not closing connection

开发者 https://www.devze.com 2023-01-02 04:26 出处:网络
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 l

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号