В моем приложении Android я хочу получить текущее местоположение пользователя каждые несколько минут и обновить его на моем центральном сервере с помощью веб-службы. В настоящее время я использую Fused Location Provide для получения текущего местоположения пользователя, см. ссылку
теперь я хочу знать, что является лучшим способом часто находить местоположение пользователя и вызывать веб-сервис.
ниже - мой код, который дает мне текущее местоположение пользователя: -
locationrequest = LocationRequest.create();
locationrequest.setInterval(10000);
locationclient.requestLocationUpdates(locationrequest,new com.google.android.gms.location.LocationListener() {
@Override
public void onLocationChanged(Location location) {
Log.i(TAG, "Last Known Location :" + location.getLatitude() + "," + location.getLongitude());
}
});
теперь, откуда я должен позвонить этому коду. Могу ли я использовать это в фоновом режиме или где-то еще.
Просьба представить вашу идею.
ТИА.