In my application I am using v4 support library to display user preferences in a ViewPager
with tabs.
Until now I was using some custom Fragment
that reproduces what PreferenceFragment
does.
For instance, there are some suggestions here.
After updating all my Android SDK to the latest versions, these custom Fragments
stopped working, in particular they seem to fail this method invocation by reflection:
static PreferenceScreen inflateFromResource(PreferenceManager manager,
Activity activity, int resId, PreferenceScreen screen) {
try {
Method m = PreferenceManager.class.getDeclaredMethod("inflateFromResource", Context.class, int.class, PreferenceScreen.class);
m.setAccessible(true);
PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(manager, activity, resId, screen);
return prefScreen;
} catch (Exception e) {
Log.w(TAG, "Couldn't call PreferenceManager.inflateFromResource by reflection", e);
}
return null;
}
Since nobody can change exposure of the method in the APIs, is it still possible to create a PreferenceScreen
starting from a XML file?