How can I send a notification from inside the onProviderDisabled method of a LocationListener?
So far I have been using:
Toast.makeText(mainmenu, "GPS Location providers are disabled... blah blah", Toast.LENGTH_LONG).show();}});
but that entails using a static mainmenu variable stored when the mainmenu class is first instantiated - I gather doing it that is a bad idea, in case the mainmenu object gets removed from memory I guess - so I think I should be using notifications.
I guess I need to be able to have a reference to an activity to make the intent - but what activity can I refer to since my location listener stores no such reference?
I'm not sure if this will work always, but you can call Application.getApplicationContext()
and use that.
If your LocationListener is part of an Activity (in the form of an inner class) you can also use this.MyActivity
.