0

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?

  • http://stackoverflow.com/questions/4997907/how-to-detect-if-changes-were-made-in-the-preferences – nano_nano Jun 19 '15 at 10:19
  • I want also to know, if the user is only in the preferences, even if no changes were made –  Jun 19 '15 at 10:20

1 Answers1

0

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.

Nanoc
  • 2,381
  • 1
  • 20
  • 35