위치 청취자를 사용하는 방법이 나에게 명확하지 않습니다. 위치 수신기를 사용하는 방법?
내가 이렇게 수행public Location actualLocation;
private class mLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
actualLocation = location;
}
public void onStatusChanged(String s, int i, Bundle b) {
}
public void onProviderDisabled(String s) {
}
public void onProviderEnabled(String s) {
}
}
//Middle of code
currentLatitude = actualLocation.getLatitude()
currentLongitude = actualLocation.getLongitude()
나이 :
이 코드 조각에 선언되지 않은 사용되는 변수가 있습니다public Location actualLocation;
private class mLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
}
public void onStatusChanged(String s, int i, Bundle b) {
}
public void onProviderDisabled(String s) {
}
public void onProviderEnabled(String s) {
}
}
//Middle of code
actualLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
currentLatitude = actualLocation.getLatitude()
currentLongitude = actualLocation.getLongitude()
. 그것은 목적입니다. 나는 코드를 단순화하기 위해 단축했다.
업데이트 : 내 질문에 : ¿ getLastKnow 위치를 사용합니까? 아니면 업데이트 될 때마다 수동으로 위치를 저장합니까? ¿ 그게 똑같이 작동할까요?
LocationListener를 사용하여 무엇을 이루고 싶습니까? –