My AppWidget's onEnabled method creates two PendingIntents. The first
is to get location updates and the second is for an ELAPSED_REALTIME
alarm. The two PendingIntents are declared as private class-level
variables so that I can access them later from different methods
(obviously). I'm having trouble canceling these PendingIntents and it
looks like its because the variable has become null. In the case of
location updates, I crash when I execute LocationManager.removeUpdates.
In the case of the alarm, I do not crash but the alarm is not canceled.
I tried putting my cancel code in onDisabled and onDeleted (not at the
same time) but it didn't work. Any suggestions?
My code looks as follows:
public void onDeleted(Context context, int[] AppWidgetIds) {
Log.d("ZMAppWidget", "onDeleted");
// cancel location updates
LocationManager lm = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
lm.removeUpdates(piLocation);
// cancel the alarm used to update the time
AlarmManager alarms = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
alarms.cancel(piAlarm);
}
Thanks.
--
Jake Colman -- Android Tinkerer
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en