2012-05-28 1 views
1

현재 BB 애플리케이션을 개발 중이며 현재 위치를 얻어야합니다.SDK 5.0 및 이후 버전의 기준 및 GPS

v5.0의 BB 모델에서는 괜찮습니다. 그러나 v6.0의 BB에서는 항상 null로 locationProvider를 얻습니다. (GPS가 켜짐).

누구나 일어날 수있는 일과 해결 방법을 알고 있습니까?

내가 사용하는 코드의 일부는 다음과 같습니다

private boolean startLocationUpdate() { 
    boolean retval = false; 

    try { 
     Criteria criteria = new Criteria(); 
     criteria.setCostAllowed(true); 
     criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT); 

     criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT); 
     criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW); 

     locationProvider = LocationProvider.getInstance(criteria); 

     if (locationProvider == null) { 

      Runnable showGpsUnsupportedDialog = new Runnable() { 
       public void run() { 

        Dialog.alert("GPS is not supported on this platform..."); 
        // System.exit(1); 
       } 
      }; 

      UiApplication.getUiApplication().invokeAndWait(
        showGpsUnsupportedDialog); // Ask event-dispatcher 
               // thread to display dialog 
               // ASAP. 
     } else { 

      locationProvider.setLocationListener(
        new LocationListenerImpl(), interval, 1, 1); 

      retval = true; 
     } 
    } catch (LocationException le) { 
     System.err 
       .println("Failed to instantiate the LocationProvider object, exiting..."); 
     System.err.println(le); 
     System.exit(0); 
    } 
    return retval; 
} 

감사합니다!

답변

0

Criteria에 대한 API 설명서에 따르면 셀 사이트 모드를 요청하고 있습니다. LocationProvider.getInstance()에 대한 문서는 지정

a LocationProvider meeting the defined criteria or null if a LocationProvider that meets the defined criteria can't be returned but there are other supported available or temporarily unavailable providers that do not meet the criteria. 

그래서 API는 셀 사이트가 지원되지 않는 사실을 말하고 있지만, 사용할 수있는 다른 지원되는 모드가 있습니다. GPS를 사용하려면 Autonomous 모드를 요구하는 기준을 지정해야합니다.

+0

다른 제공 업체를 시도했지만 그 결과는 같습니다. S. 정말 이상합니다. BB Torch에서만 작동하지 않습니다. 도와 줘서 고마워. – oriolpons

+0

나는 잠시 동안 7.0과 7.1에서 일해왔다. 6.0 문제는 기억이 안납니다. 나는 normallall null 기준을 사용합니다. – Richard