Android Runtime GPS Location - Blackberry Device - not working

China☆狼群 提交于 2019-12-23 18:27:45

问题


My app has been ported from Android to blackberry and it works fine...

the only thing not working is the GPS location which works on the android....

the app displays a message to the using that we are trying to find the location and if no location is found we tell the user that we could not retrieve a location..

here is the code

private void gpsLocation()
   {
         //Get the location manager
         locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
         //Provide Criteria
          Criteria criteria = new Criteria();
         provider = locationManager.getBestProvider(criteria, false);
          Location location = locationManager.getLastKnownLocation(provider);

         locationManager.requestLocationUpdates(provider, 400, 1, this);

         if(location != null){

                 onLocationChanged(location);
          } else{
                 Log.i(TAG, "no GPS location available - waiting for GPS fix");

                 Toast.makeText(getApplicationContext(), R.string.gpsWaitingToast, Toast.LENGTH_SHORT).show();

                if (Debug.GPS_USE_MONTREAL) {
                      currentLatitude = Double.valueOf(Debug.GPS_LAT_MONTREAL); currentLongitude = Double.valueOf(Debug.GPS_LNG_MONTREAL); // montreal
                 }
                 waitForGpsFix(GPSFIX_DELAY);
          }

its not working,, I restarted the app ,, did it next to a window and all that stuff..

nothing works..

your advise and help is greatly appreciated.

Regards


回答1:


There was previously a bug where LocationManager.NETWORK_PROVIDER returned null, which may still be returned by the locationManager.getBestProvider() method. This should be fixed in the newer OS builds, however.

If you'd like to fix your code immediately, all you would need to do would be to set:

provider = LocationManager.GPS_PROVIDER

as in the early stages, GPS_PROVIDER was the only provider that was implemented in the player.



来源:https://stackoverflow.com/questions/15550521/android-runtime-gps-location-blackberry-device-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!