사용자 좌표를 얻으려면 LocationManager을 사용해야합니다.이 answer을 살펴보면 좌표 획득 방법에 대해 자세히 알 수 있습니다. 그 답변에 따라, 당신은 위치 관리자 생성 :
이
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
longitude = location.getLongitude();
latitude = location.getLatitude();
다음 생성 및 위치 관리자에 locationListener
객체를 첨부 : 당신은 좌표가 있으면
lm.requestLocationUpdates(lm.getBestProvider(fine, true), minTime, 0, listenerFine);
, 당신은 할 수 Geofencing을 사용하십시오. 여기에 지오 펜스 생성 및 모니터링에 대한 설명서의 간략한 내용이 있습니다.
mGeofenceList.add(new Geofence.Builder()
.setRequestId("geofenceRequestID")
.setCircularRegion(latitude, longitude, 480f)
.setExpirationDuration("300000") // duration is in millis (5mins)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.build());
Geofence.Builder 사용에 대한 자세한 내용은 details입니다.
고정 된 위치 (또는 고정 된 위치의 작은 세트)가 지오 펜스를 사용하는 경우. –