Hello there, Answer of the 3rd question is u have given the COARSE permission and GPS required FINE permission so u cant get gps...
And if u want to use network provider then go for telephony manager rather than location manager.. * * Check this out... dhavalsuchak.blogspot.com On Mon, Mar 7, 2011 at 7:25 PM, Jake Colman <[email protected]> wrote: > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

