0

我正在制作一个安卓应用程序。我有一个主要活动,我想在主要活动中显示距离和速度。但是在主要活动上也有一个按钮查看地图。如果用户点击它,那么他/她应该在地图上看到他/她的行进轨迹。用户应该停止他/从主要活动中运行意味着用户应该能够回到主要活动然后停止。如何创建在后台运行的地图活动并在主要活动中显示距离和速度。提前致谢。

4

2 回答 2

0

您应该看看 Google MyTracks 应用程序,它完全符合您的要求,而且它是开源的。

http://code.google.com/p/mytracks/

于 2012-07-05T12:51:24.277 回答
0

You should probably not think about having an Activity run in the background and instead have some other object that manages all the location information. Most of the time, you only have one Activity on screen and when its not on screen, it is paused and not working.

I would try to have an class that extends LocationListener, manage location information in that object, then whenever it is needed, plug the information into an appropriate View that is shown when the user presses "View Map" button you have.

于 2012-07-05T13:14:24.003 回答