출구에서
geoFence
을 업데이트해야합니다. 이를 위해서는 그 시점에서 현재 위치가 필요합니다. 내 응용 프로그램이을 닫을 때지오 펜스의 현재 위치 얻기 .GEOFENCE_TRANSITION_EXIT
나는 onLocationChanged
에 대한 리스너가 없습니다. 그리고 geoFence를 업데이 트하려면 내 위치가 필요합니다. 잘 작동
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
int resultCode = bundle.getInt("done");
if (resultCode == 1) {
if(!MainActivity.isGeoFenceAdded){
updateGeoFencesOnCurrentExit();//I need current location here
}
}
}
}
};
모든 것은 MainActivity에 Geofence.GEOFENCE_TRANSITION_EXIT
public void broadcastUpdateGeoFences() {
MainActivity.isGeoFenceAdded = false;//It tells to update geoFence
Intent intent = new Intent(Constants.RECEIVER_GEOFENCE);
intent.putExtra("done", 1);
sendBroadcast(intent);
}
방송 수신기에서 현재 위치를 얻기 위해 자신의 방법이입니다. 하지만 앱을 종료하면 exit시 currentLocation을 전달할 수있는 방법을 찾을 수 없습니다. 그들은 한 번 파괴 할 수 있기 때문에
private void updateGeoFencesOnCurrentExit(Location currentLocation){
locationHandler.updateGeoFences(currentLocation);
}
여기에 의도 서비스를 사용하고 있습니까? – mechdon
예 브로드 캐스트 수신기 여야한다는 것을 알고 있습니다. – Nepster
실제 지오 펜스 추가 요청은 어디에 있습니까? –