Monday, June 6, 2011

[android-developers] Unable to get location from within AppWidgetProvider

I am able to get location (GPS or Network provider) with no issue from
any Activity (in my main app). But when I tried from my App Widget, I
am not getting the call back.

I see the GPS location icon flashes in the status bar indefinitely
(clearly triggered by my widget call) but there was no
onLocationUpdate callback (I waited a long time).

I am getting the provider String successfully and called the below:

lManager = (LocationManager)
context.getSystemService(Context.LOCATION_SERVICE);
lManager.requestLocationUpdates(provider, MIN_TIME_MS, MIN_DIST_METER,
this);

I called above from an IntentService's onHandleIntent method started
by my widget.

So I thought maybe I need to use a PendingIntent instead so I tried:
lManager = (LocationManager)
context.getSystemService(Context.LOCATION_SERVICE);
Intent newLocationFoundIntent = new
Intent(ACTION_LOCATION_PROVIDER_UPDATE);
PendingIntent pIntent = PendingIntent.getBroadcast(context, 0,
newLocationFoundIntent, 0);
lManager.requestLocationUpdates(provider, MIN_TIME_MS, MIN_DIST_METER,
pendingIntent);

I tried this call from both onReceive and from my IntentService but my
receiver never got ACTION_LOCATION_PROVIDER_UPDATE.

I am out of ideas completely. I tried this on my Samsung Nexus S.
Please help.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment