버튼 클릭으로 경도와 위도로 위치 정보를 가져 오는 Android 앱을 만들었습니다.Android GPS가 정확한 시간이 걸립니다.
처음에는 앱을로드 할 때/gps를 켜면 처음에는 내가 알고있는 마지막 위치 정보를 얻습니다.
Google지도에서 '위치 대기 중'이라는 축배 메시지를받을 때처럼 정확할 때까지 기다리는 방법을 알고 싶습니다.
코드를 향상시킬 수있는 방법이 있으면 도움이 될 것입니다. 참조
코드 : 읽기
public class Clue extends Activity {
public static double latitude;
public static double longitude;
Criteria criteria;
LocationManager lm;
LocationListener ll;
Location location;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.questions);
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new MyLocationListener();
lm.requestLocationUpdates(lm.getBestProvider(criteria, true), 0, 0, ll);
}
private boolean weAreThere() {
location = getLocation();
longitude = location.getLongitude();
latitude = location.getLatitude();
return inCorrectPlace(param);
}
private Location getLocation() {
lm.requestLocationUpdates(lm.getBestProvider(criteria, true), 0, 0, ll);
return lm.getLastKnownLocation(lm.getBestProvider(criteria, true));
}
}
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
Clue.longitude = loc.getLongitude();
Clue.latitude = loc.getLatitude();
}
}
덕분에, 모든 응답은 이해할 수있을 것이다.
벤
최고의 공급 업체에 반대하는 모든 공급자를 사용 어쩌면 생각? 그것은 매우 정확하지 않아야합니다. –