大家好,我正在开发两个应用程序,一个用于管理,另一个用于其员工。现在,我想要跟踪员工设备,使用这个应用程序,位置是发送到服务器时,雇员设备的位置,changed.Location是发送时,只有在位置改变。当位置发生变化时,如何将设备的位置发送到服务器??其次,我想在管理应用程序地图上显示员工的位置,因为它正在改变位置。(我可以通过GCM或任何其他技术从服务器发送位置坐标到管理应用程序吗?)
嘿,选民们,你能解释一下这个问题是怎么回事吗?如果你有一个问题的答案,给出否则试着理解问题。请提前帮忙谢谢。
发布于 2014-11-25 06:30:04
public LatLng getLocation()
{
// Get the location manager
MyLocationListener myLocListener = new MyLocationListener();
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String bestProvider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(bestProvider);
locationManager.requestLocationUpdates(bestProvider,timeAfteryougetUpdate, minDistanceAfterYougetupdate, myLocListener);
Double lat,lon;
try {
lat = location.getLatitude ();
lon = location.getLongitude ();
return new LatLng(lat, lon);
}
catch (NullPointerException e){
e.printStackTrace();
return null;
}
}**使用这个获取位置**
private class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc)
{
if (loc != null)
{
// Do something knowing the location changed by the distance you requested
methodThatDoesSomethingWithNewLocation(loc);
}
}
@Override
public void onProviderDisabled(String arg0)
{
// Do something here if you would like to know when the provider is disabled by the user
}
@Override
public void onProviderEnabled(String arg0)
{
// Do something here if you would like to know when the provider is enabled by the user
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2)
{
// Do something here if you would like to know when the provider status changes
}
}发布于 2014-11-25 06:29:39
您可以使用服务实现locationListener,您可以从服务器重新定义api,并以任何形式( json、xml )发送数据,一旦得到协调,就可以将它们显示到地图上。
LocationListener
android-基于位置的服务.示例
希望这些能帮到你。
发布于 2020-12-10 07:16:59
我知道我的反应有点晚了。
我将解释我的答案,使用谷歌地图,服务和火灾的实时数据库和google,以方便的位置上传到云数据库。
https://stackoverflow.com/questions/27119877
复制相似问题