Question

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!

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top