Java Code Examples for android.preference.PreferenceManager#OnActivityDestroyListener

The following examples show how to use android.preference.PreferenceManager#OnActivityDestroyListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferenceManagerEx.java    From MaterialPreferenceLibrary with Apache License 2.0 6 votes vote down vote up
public void unregisterOnActivityDestroyListener(PreferenceManager pm, PreferenceManager.OnActivityDestroyListener listener) {
        Method unregisterMethod = METHOD_UNREGISTER_ON_ACTIVITY_DESTROY_LISTENER;
        try {
            if (unregisterMethod == null) {
                //this is used to hook to the onActivityDestroy method, to avoid a window leak when config-changes while the dialog is shown
                unregisterMethod = pm.getClass().getDeclaredMethod("unregisterOnActivityDestroyListener",
                        PreferenceManager.OnActivityDestroyListener.class);
                unregisterMethod.setAccessible(true);
            }
            unregisterMethod.invoke(pm, listener);
        } catch (Exception e) {
            e.printStackTrace();
//      unregisterMethod=null;
        }
        METHOD_UNREGISTER_ON_ACTIVITY_DESTROY_LISTENER = unregisterMethod;
    }
 
Example 2
Source File: PreferenceManagerEx.java    From MaterialPreferenceLibrary with Apache License 2.0 6 votes vote down vote up
public void registerOnActivityDestroyListener(PreferenceManager pm, PreferenceManager.OnActivityDestroyListener listener) {
        //
        Method registerMethod = METHOD_REGISTER_ON_ACTIVITY_DESTROY_LISTENER;
        try {
            if (registerMethod == null) {
                //this is used to hook to the onActivityDestroy method, to avoid a window leak when config-changes while the dialog is shown
                registerMethod = pm.getClass().getDeclaredMethod("registerOnActivityDestroyListener",
                        PreferenceManager.OnActivityDestroyListener.class);
                registerMethod.setAccessible(true);
            }
            registerMethod.invoke(pm, listener);
        } catch (Exception e) {
            e.printStackTrace();
//      registerMethod=null;
        }
        METHOD_REGISTER_ON_ACTIVITY_DESTROY_LISTENER = registerMethod;
    }
 
Example 3
Source File: MaterialEditTextPreference.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
public static void registerOnActivityDestroyListener(@NonNull Preference preference, @NonNull PreferenceManager.OnActivityDestroyListener listener) {
    try {
        PreferenceManager pm = preference.getPreferenceManager();
        Method method = pm.getClass().getDeclaredMethod(
                "registerOnActivityDestroyListener",
                PreferenceManager.OnActivityDestroyListener.class);
        method.setAccessible(true);
        method.invoke(pm, listener);
    } catch (Exception ignored) {
    }
}