Merhaba Bir Android App oluşturuyorum. bir Navigasyon modülü dahil ediyorum. Burada kullanıcının konumunu 20 saniyelik bir aralıkta otomatik olarak kontrol etmek istiyorum, bu konum değişikliği olayını tetiklemek için herhangi bir tuşa basmak istemiyorum. Bu yöntem, gerçek zamanlı Google Map navigasyon sistemi gibi otomatik olarak çalışmalıdır. Kullanıcının konumunu FusedLocationAPI
ve LocationListener
kullanarak getiriyorum. Bu yöntemi oluşturdum. İşteKullanıcının Konumunu periyodik olarak 20 San. otomatik olarak
private void onLocationUpdate() {
lr.setInterval(20000).setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, lr, (com.google.android.gms.location.LocationListener) this);
}
lr
LocationRequest
bir nesnedir. Lütfen bana bu yöntemi nerede aramalıyım söyle. Ve onLocationChanged(Location location)
'un altında Kullanıcının geçerli konumunda işaretleyici ekliyorum. Bir hizmeti oluşturmanız gerekecektir