Thanks guys, didnt think of sending a broadcast, seems like the best
idea, since then I wont need to do any context caching (:

On May 13, 1:40 pm, adamphillips12 <[email protected]> wrote:
> Well there's a few things you can do in this situation.
>
> You can do this:
>
> public class MyClass {
>   public void doProviderEnabledStuff(String provider){}
>
>   MyLocListenerClass myListner = new MyLocListenerClass() {
>     public void onProviderEnabled (String provider) {
>        doProviderEnabledStuff(provider);
>     }
>   };
>
> }
>
> Or you can just extend your class constructor to require a context and
> use that object to get your preferences, you probably want to use the
> application context for such a thing.
>
> Or for a more general solution, you can tell your extended class to
> broadcast an Intent and who ever cares to listen can register for it.
>
> On May 13, 9:35 pm, "[email protected]"
>
> <[email protected]> wrote:
> > I am currently encountering issues when extending the GPS
> > LocationListener class. The issue that I am seeing is when I get an
> > update via onProviderEnabled(String provider), I am unable to change
> > the SharedPreferences used by my application.
>
> > The problem here is that since I am not passed a context by
> > onProviderEnabled, I cant see a way of calling the function
> > context.getSharedPreferences, I have tried manually generating a new
> > context via creating a new instance of an activity, but this seems to
> > create a nullPointerException when getting shared prefs.
>
> > Surely I must be missing something here?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to