8

My app supports from 2.2 to the lates Android version. The thing is that for Settings page, I am using PreferenceActivity now. However, as you know, many of its methods are deprecated and they tell me to use Fragment based settings. However, I found that if I switch to use PreferenceFragment and Fragment Activity, I cannot support 2.2 and 2.3 anymore because PreferenceFragment is supported above API level 11. Even if I use support library, it doesn't contain PreferenceFragment! I don't know why Google didn't add PreferenceFragment in the support library.

Anyways, I think I can still use the old PreferenceActivity but if it says it is deprecated, why doesn't it support an alternative in its support library?

Any advice is appreciated!

user2062024
  • 3,541
  • 7
  • 33
  • 44

1 Answers1

6

Just because it is deprecated does not mean it stops working - newer devices still support PreferenceActivity without issue. However, on larger devices (such as 10" tablets), the dual pane support of PreferenceFragment/PreferenceHeaders looks much better. Until Google adds them to the Support Library, you can use third party libraries such as UnifiedPreferences to use a single API for all versions of Android.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks. Maybe I will just have to wait... I still don't understand why Google hasn't added it until revision 13. I suspect that they will not add it at all or can there be any other reason? hmmm – user2062024 Jul 16 '13 at 21:35
  • i think actionBarSherlock also has its own preference activity, no? – android developer Jul 16 '13 at 21:43
  • @androiddeveloper - it has a `SherlockPreferenceActivity` to add an action bar to a `PreferenceActivity`, but it does not add support for `PreferenceFragment`/`PreferenceHeaders`. Note that UnifiedPreferences works with ABS as well. – ianhanniballake Jul 16 '13 at 22:28
  • @androiddeveloper - as per [this](https://github.com/JakeWharton/ActionBarSherlock/issues/43) and [this](https://github.com/JakeWharton/ActionBarSherlock/issues/411) ticket, `PreferenceFragment` relies on package visible methods in `PreferenceScreen` and `PreferenceManager` and is therefore out of scope of ABS and therefore is more appropriate for another library that specifically deals with Preferences, such as UnifiedPreferences. – ianhanniballake Jul 17 '13 at 16:11
  • @ianhanniballake i see. thank you. wish we had a single library which is a total port of android 4. today we have actionBarSherlock, nineOldAndroids, holoEverywhere, and now this... – android developer Jul 17 '13 at 16:30