Michael,

According to Android documentation the following call
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, this);
requests updates from WiFi or cellular network which means you should
get some update (from cell tower) even if WiFi location is not
available. However, I've seen cases when Google map application failed
to set map to "MyLocation" for several minutes while driving on a
freeway.

Back to your code. I think you need to replace
getLastKnownLocation(mCoarseLocationProvider) with
getLastKnownLocation(LocationManager.NETWORK_PROVIDER) - it is not
clear where do you get mCoarseLocationProvider.
Also you don't need to use LocationProvider variable in your code
fragment:
     public MyLocationListener() {
         mLocMan =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);

         if
(mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) !=
null) {
             mCurrentLocation =
mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
         }

        
mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
this);
     }


Check the following link which has a lot of useful suggestions:
http://developer.android.com/guide/topics/location/obtaining-user-location.html

Bets regards
Igor


On Nov 29, 2:44 pm, michael <michael.d.peder...@googlemail.com> wrote:
> Let me also add that the location listener does sometimes get calls to
> onProviderEnabled -- this happens after asking the user to enable
> wireless network locations if initially disabled. So I know for sure
> that the listener is registered correctly. It just never gets an
> onLocationChanged call.
>
> /Michael.
>
> On Nov 29, 10:10 pm, michael <michael.d.peder...@googlemail.com>
> wrote:
>
>
>
>
>
>
>
> > Hi folks,
>
> > I have a location listener running in a foreground service. The
> > listener registers for wireless network updates in its constructor. In
> > the majority of cases, location updates are received as expected.
>
> > However, log entries from the live app show that for about 5% of my
> > users, location updates are never received even though wireless
> > network location is enabled on the phone (I check this through the
> > LocationManager.isProviderEnabled method). That is, onLocationChanged
> > is never called, at least not within say 20 minutes of registering the
> > listener.
>
> > Does anybody have any idea why this might be? Are there cases, or
> > certain geographic areas, where you would not expect wireless
> > locations to be available?
>
> > A stripped-down outline of the location listener code is shown below:
>
> > class MyLocationListener extends LocationListener {
> >     private Location mLocation = null;
>
> >     public MyLocationListener() {
> >         mLocMan = (LocationManager)
> > getSystemService(Context.LOCATION_SERVICE);
>
> >         if (mLocMan.getLastKnownLocation(mCoarseLocationProvider) !=
> > null) {
> >             mCurrentLocation =
> > mLocMan.getLastKnownLocation(mCoarseLocationProvider);
> >         }
>
> >         LocationProvider lp =
> > mLocMan.getProvider(LocationManager.NETWORK_PROVIDER);
> >         mLocMan.requestLocationUpdates(lp.getName(), 0, 0, this);
> >     }
>
> >     public void onLocationChanged(Location loc) {
> >         mLocation = loc;
> >     }
>
> > }
>
> > I verify through flurry logs that the "network" location provider is
> > indeed obtained and enabled, and that mLocation == null after about 20
> > minutes.
>
> > Any suggestions would be enormously appreciated. I am running out of
> > ideas for how to fix this, and I cannot replicate the issue on my own
> > test devices.
>
> > Cheers,
> > Michael.

-- 
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