2011-05-13 1 views
0

나는 안드로이드 개발의 초보자이며 gps로 사용자 위치를 얻으려고 triying입니다.사용자 위치 오류 받기

은 무엇인가 "유형 불일치 : 문자열에서 변환 할 수 없습니다 것은 LocationProvider하는"

LocationProvider locationProvider = LocationManager.GPS_PROVIDER; 

내가 이런 오류가 얻을이 줄

// Define a listener that responds to location updates 
      LocationListener locationListener = new LocationListener() { 
      public void onLocationChanged(Location location) { 
       // Called when a new location is found by the network location provider. 
      // makeUseOfNewLocation(location); 

       LocationProvider locationProvider = LocationManager.GPS_PROVIDER; 


      } 

: 나는 다음과 같은 코드의 오류를 줄 그 줄의 문제

답변

0

다른 사람의 코드를 디버깅 할만큼 충분하지 않지만이 코드

public class mainActivity extends Activity { 

private MyLocationListener mLocationListener; 
private LocationManager mLocationManager; 
private Location currentLocation; 




public class MyLocationListener implements android.location.LocationListener { 


    public void onLocationChanged(Location location) { 
     // This is where I finally get the latest location information 

     currentLocation= location; 

     int Bearing = (int)currentLocation.getBearing(); 

} 


public void onCreate(Bundle savedInstanceState) { 

    mLocationManager = (LocationManager) this.getSystemService(LOCATION_SERVICE); 
    mLocationListener = new MyLocationListener(); 

} 

protected void onResume() { 

    String provider = LocationManager.GPS_PROVIDER; 
    long minTime = 0; 
    float minDistance = 0; 
    mLocationManager.requestLocationUpdates(provider, minTime, minDistance,mLocationListener); 

} 

protected void onPause() { 
    mLocationManager.removeUpdates(mLocationListener); 
} 

}

내가 위치 정보

관련 사이먼

을 얻기 위해 내 애플 리케이션 중 하나에서 사용하는 것입니다