I found that this worked for every preference I had that persisted a
value, but the 'Clear Cache' button doesn't seem to work. I tried
extending DialogInterface then using this code:
public void onClick(DialogInterface dialog, int which) {
        if(which == DialogInterface.BUTTON_POSITIVE){
                callChangeListener(true);
        }
        super.onClick(dialog, which);
}

but I still get nothing back from the preference listener. Any ideas?

By the way, I like your book a lot!
Kieran

On Nov 14, 1:38 am, Mark Murphy <mmur...@commonsware.com> wrote:
> Kieran wrote:
> > Hi,
> > I think I've missed something in how Android is supposed to work!
> > I have the main Activity with a menu option that opens thepreferences
> > screen. What I need is a way for any changes that were made to be
> > communicated back to the main Activity as soon as the preference is
> > activated. At the moment the only way I could get it working is by
> > using the intent data that gets sent back when the prefs activity
> > closes but this isn't really enough. The reason why it needs to be
> > instantaneous is that one of thepreferencesis a 'Clear cache'
> > button, so I would like the data to be deleted when the user requests
> > it and no later!
>
> Attach a preference listener:
>
> http://developer.android.com/reference/android/content/SharedPreferen...)
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 2.8
> Available!

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