1
모든 위치 업데이트에 5 초마다 메시지를 수신하는 핸들러가 있습니다. 위치에서 사용자가 들어오는 현재 도시를 요청할 수 있습니다. 그러면 도시가 바뀔 때만 데이터를 한 번 다운로드하고 싶습니다. 내가 어떻게 깨달을 수 있니?UpdateHandler, 트리거가 참일 때만 작업하십시오. Android
Handler myViewUpdateHandler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case UPDATE_LOCATION:
mc.animateTo(geosenseo.getCurrentPoint());
mapView.invalidate();
//a async task sets the currentCity field
if(trigger && (currentCity != "")){
firstCity = currentCity;
trigger = false;
}
if((currentCity != "") && (firstCity != "")){
if(firstCity != currentCity){
//download only when city changes
trigger = true;
}
}
}
super.handleMessage(msg);
}
};
내가 vars와 함께 놀았습니다. 어떤 아이디어? 감사
가 어떻게 위치에서 현재 도시를받을 경우 다음을 비교? – Pentium10
// 비동기 작업으로 표시된 코드에서 currentCity 필드를 설정합니다. asynctask를 시작합니다. 배경에서 일부 지리 데이터를 다운로드합니다.이 경우 도시에서는 지오 코더를 사용합니다. import android.location.Address; import android.location.Geocoder; –