Reputation: 5276
I'm new to android and am working on my first app. I tried to add a settings activity and Eclipse loaded a bare-bones class that utilized deprecated functions like addPreferencesFromResource
. I looked at the android developer settings guide, but it didn't address any code. So then I looked at sample code in the PreferenceActivity reference material, but it didn't break things down enough for me to really understand. So I've been looking for another guide/tutorial.
My impression from the PreferenceActivity material was that the current paradigm is to populate PreferenceFragments instead of PreferenceActivities. But I can't find a clear tutorial on using this approach. Most tutorials I find use PreferenceActivities and deprecated functions.
So I know it's not as specific as most questions should be on this site, but I could use some guidance and a clear answer on what the current paradigm is because I don't want to learn out-dated methods.
I only have two or three settings I want to implement, so this should be pretty simple. But I want to do it right.
Upvotes: 1
Views: 63
Reputation: 93561
So here's the difference between the two: with preference fragment, if the phone has a settings app with a master detail flow AND you're embedded into the system settings, when you open your specific settings it will be embedded and not go fullscreen. That's why Android moved to PreferenceFragment.
In reality- I don't know of any device that actually does that. I know on Samsung devices, by far the most common, everything uses full screen activities. So its kind of an idea they went for that died horribly.
So the PreferenceFragment is what Google wanted people to use, but pretty much nobody actually does. And unless your app was going to be embedded in system settings (like a keyboard's settings are), it wouldn't matter anyway. So my advice would be to go the simpler route and not worry about it- just use a PreferenceActivity.
Upvotes: 2