Check enter and leave Preferences

94 views Asked by At

I'm using a PreferenceFragment and some headers to manage my application settings like in this official tutorial: http://developer.android.com/guide/topics/ui/settings.html#Fragment

You can call Preferences by the ActionBar in several Activities.

Now I want to detect, if a user enters oder leaves the preferences. How can I do that?

My approach is using the lifecycle methods like: onCreate, onResume, onPause ....

But is there another solution like a listener or something else?

1

There are 1 answers

0
Nanoc On BEST ANSWER

You can override onBackPressed on PreferenceFragment to call a interface method that is implemented on your caller/s activity.

That way you can notify what you need to your activitys.

public interface PreferenceInterface
{
   public abstract void preferencesClosed();
   public abstract void preferencesOpened();
}

I hope this is what you are looking for.