package com.jenzz.materialpreference.sample;

import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceFragment;
import android.support.v7.app.ActionBarActivity;

/**
 * Created by jenzz on 28/01/15.
 */
public class SettingsActivity extends ActionBarActivity {

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // workaround for https://code.google.com/p/android/issues/detail?id=78701
    new Handler().post(new Runnable() {
      @Override public void run() {
        getFragmentManager().beginTransaction()
            .replace(android.R.id.content, new SettingsFragment())
            .commit();
      }
    });
  }

  public static class SettingsFragment extends PreferenceFragment {

    @Override public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.prefs);
    }
  }
}

@@ -69,35 +69,8 @@
 le;%0A
-import android.os.Handler;%0A
 impo
@@ -165,16 +165,70 @@
 y;%0A%0A/**%0A
+ * Simple Activity to display example preferences.%0A *%0A
  * Creat
@@ -429,161 +429,42 @@
     
-// workaround for https://code.google.com/p/android/issues/detail?id=78701%0A    new Handler().post(new Runnable() %7B%0A      @Override public void run(
+if (savedInstanceState == null
 ) %7B%0A
-  
     
@@ -505,18 +505,16 @@
 ction()%0A
-  
         
@@ -520,15 +520,11 @@
    .
-replace
+add
 (and
@@ -576,18 +576,16 @@
         
-  
 .commit(
@@ -595,19 +595,9 @@
     
-  %7D%0A    %7D);
+%7D
 %0A  %7D

Fix rotation duplicating fragment in sample