2012-05-30 1 views
0

위치 기반 알람 앱을 만들었습니다. 에뮬레이터에서 모든 것이 잘 작동합니다. 그러나 실제 장치에서는 다음과 같은 오류가 발생합니다.GPS 문제가 처음으로 발생하지 않습니다. 알림 바에 상태 없음

시나리오 :

GPS가 켜져 있습니다. 전화로 내 앱을 열었습니다. 상태 표시 줄에 GPS 기호가 없습니다. 앱이 강제 종료되었습니다.

나는 다음과 같은 일이

지도를 열고, GPS 필수와 같은 응용 프로그램을하고있는 중이 야,이 시나리오를 해결하려면. 내 GPS 값이 고쳐지고 있습니다. 그 후 내 응용 프로그램을 엽니 다. 앱이 정상적으로 작동합니다.

아래에 필요한 코드 제공 : 내에서 OnCreate 방법에

fixlocation = orgManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); 


@Override 
protected void onResume() { 
    super.onResume(); 
    orgManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1000, this); 
    orgManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 1000, this); 
    mo.enableCompass(); 
    mo.enableMyLocation(); 
} 

/** Stop the updates when Activity is paused */ 
@Override 
protected void onPause() { 
    super.onPause(); 
    orgManager.removeUpdates(this); 
    mo.disableCompass(); 
    mo.disableMyLocation(); 
} 



@Override 
    public void onLocationChanged(Location location) { 
     // TODO Auto-generated method stub 

     //orgManager.removeUpdates(this); 

     if (location != null) { 
      currLatitude = location.getLatitude(); 
      currLongtitude = location.getLongitude(); 
}} 

는 내가 지금 어떻게해야합니까?

답변

0
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); 

currLat = location.getLatitude(); 
currentLang = location.getLongitude(); 

현재 위치를 확인해보십시오. onLocationChanged 만 호출

때 기기 변경의 위치에 있지만 응용 프로그램이 코드를 사용할 수 있습니다 시작

처음.

+0

대신에 내가 지정한 위치 대신, 위치 개체 인 fixlocation을 사용했습니다. 수락을 위해 – Satheesh

+0

고마워 ... – MAC

관련 문제