마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

gps null 포인트 반환 해결방법좀 알려주세요 ㅠ

0 추천
String context = Context.LOCATION_SERVICE;
  
  locationManager = (LocationManager) getSystemService(context);
  Criteria criteria = new Criteria();
  criteria.setAccuracy(Criteria.ACCURACY_FINE); // 정확도
  criteria.setPowerRequirement(Criteria.POWER_LOW); // 전원 소비량
  criteria.setAltitudeRequired(false); // 고도, 높이 값을 얻어 올지를 결정
  criteria.setBearingRequired(false); // provider 기본 정보
  criteria.setSpeedRequired(false); // 속도
  criteria.setCostAllowed(true);

  if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
  {
   String provider = locationManager.getBestProvider(criteria, true);
   lastKnownLocation = locationManager.getLastKnownLocation(provider);
//   lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    Log.e("위도", "" + lastKnownLocation.getLatitude());
    Log.e("경도", "" + lastKnownLocation.getLongitude());
    Latitude = lastKnownLocation.getLatitude();
    Longitude = lastKnownLocation.getLongitude();
   

  } else
  {
   lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
   
   Latitude = lastKnownLocation.getLatitude();
   Longitude = lastKnownLocation.getLongitude();
   Log.e("위도", "" + Latitude);
   Log.e("경도", "" + Longitude);
   //mview.reload();
  }

lastKnownLocation = locationManager.getLastKnownLocation(provider);
lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

여기서 맨밑에 두줄에서 null 포인트를 반환하게되는데 여기서 공기계인 갤럭시 노트 10.1 에서만  null포인트가 반환됩니다.

이부분을 해어떻게 해결해야될까요?ㅠ

 

스릉스릉 (1,260 포인트) 님이 2014년 1월 23일 질문

1개의 답변

0 추천

이게 처음에 Network Provider에 처음에 저장된게 없어서 null이 뜨는것이고요..

http://stackoverflow.com/questions/20438627/getlastknownlocation-returns-null

참고해 보세요~

 

노예의집 (23,370 포인트) 님이 2014년 1월 23일 답변
...