My appwidget seems to work for every user except this one guy with a
Droid2.  The app needs to be kept apprised of the user's current
location but is happy with a coarse location.

I use the following code for tracking the user's location:

public void setDynamicLocation()
{
  logger.verbose( TAG, "Setting dynamic location" );

  // list all known providers

  List<String> all = mLocationManager.getAllProviders();
  logger.debug( TAG, "All available location providers: " + all.toString() );

  // find the best location provider available

  Criteria criteria = new Criteria();
  criteria.setAccuracy( Criteria.ACCURACY_COARSE );
  criteria.setAltitudeRequired( false );
  criteria.setBearingRequired( false );
  criteria.setCostAllowed( true );
  criteria.setPowerRequirement( Criteria.POWER_LOW );

  String provider = mLocationManager.getBestProvider( criteria, true );
  logger.debug( TAG, "Best location provider: " + provider );

  // register for location updates

  setListenerInitialized( true );
  mLocationManager.requestLocationUpdates( provider != null ? provider
                                               : 
LocationManager.NETWORK_PROVIDER,
                                           LOCATION_PERIOD,
                                           LOCATION_CHANGE_TRIGGER,
                                           this );
}

For this specific user, I see the following in my log:

    Setting dynamic location
    All available location providers: [network, passive, gps]
    Best location provider: null
    onProviderDisabled: network

That last entry is coming from my listener.

My user tells me that the phone is in good working order, that he uses
it to make phone calls, and that his GPS is functioning and on.  So here
is what I need to understand:

1) Why would getBestProvider return null?  Shouldn't it always be able
   to tell me something?

2) Why would a network provider be disabled?  Shouldn't that always be
   available - assuming that you are not in airplane mode and can make
   phone calls?

3) If the GPS is on, shouldn't my code pick up the GPS if network is
   disabled?

-- 
Jake Colman -- Android Tinkerer

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to