Code example for Constructor

Methods: newInstance, setAccessible

0
     * @return The {@link PreferenceManager} used by this activity. 
     */ 
    private PreferenceManager onCreatePreferenceManager() {
        try { 
            Constructor<PreferenceManager> c = PreferenceManager.class.getDeclaredConstructor(Activity.class, int.class);
            c.setAccessible(true);
            PreferenceManager preferenceManager = c.newInstance(this.getActivity(), FIRST_REQUEST_CODE);
            return preferenceManager;
        } catch (Exception e) {
            e.printStackTrace();
            return null; 
        } 
    } 
 
    public interface OnPreferenceAttachedListener { 
        public void onPreferenceAttached(PreferenceScreen root, int xmlId);
    } 
 
}