简体   繁体   English

获取用户的GPS位置并将其存储

[英]Get the user's GPS location and store it

It want to keep an array (Java generics for example: List) of the last 10 coordinates in order of retrieval so latest coordinates are always at the top of the stack etc. If I ask for this array we can then go back to see what steps the user took by tracing there steps.Please help me here. 它希望按检索顺序保留最后10个坐标的数组(例如Java泛型:List),以便最新的坐标始终位于堆栈的顶部等。如果我要此数组,则可以返回以查看什么用户可以通过跟踪步骤进行操作。请在此处帮助我。 Thanks 谢谢

First you need to read about how to retrive the user GPS location. 首先,您需要阅读有关如何检索用户GPS位置的信息。

http://www.vogella.com/articles/AndroidLocationAPI/article.html http://www.vogella.com/articles/AndroidLocationAPI/article.html

Then make your class implement android.location.LocationListener and in the onLocationChanged() callback just add the location to the list. 然后,让您的类实现android.location.LocationListener,并在onLocationChanged()回调中将位置添加到列表中。

@Override
public void onLocationChanged(Location location) {
   list.add(location);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM