장치가 네트워크 제공 업체에 의해 위치 정보를 얻을 때 경도와 위도를 가져와 geopoint로 변환 할 수 있지만 gps를 사용할 때 오류가 발생합니다. 이 문제를 해결하려면 어떻게해야합니까?GPS로 위도와 경도를 가져 오지 못하지만 Android의 네트워크 제공 업체가 지원합니까?
public void onCreate(Bundle savedInstanceState) {
...
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (mLocation != null) {
gp1 = getGeoByLocation(mLocation);
gp2 = gp1;
refreshMapView();
if(!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000,
10, mLocationListener);
}else{
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000,
10, mLocationListener);
}
private GeoPoint getGeoByLocation(Location location) {
GeoPoint gp = null;
try {
if (location != null) {
double geoLatitude = location.getLatitude() * 1E6;
double geoLongitude = location.getLongitude() * 1E6;
gp = new GeoPoint((int) geoLatitude, (int) geoLongitude);
}
} catch (Exception e) {
e.printStackTrace();
}
return gp;
}
무엇이 문제입니까? 로그에서 무엇을 볼 수 있습니까? –
gps를 사용할 때 위도와 경도에 대한 문자열을 표시 할 수없고 GPS를 사용할 때 내 위치를 가리키는 이미지 ( –