title: Restart application after onSharedPreferenceChanged has been called
body: <p>How to restart the application after onSharedPreferenceChanged has been called?</p>
  
  <p><strong>ActivityPreferences.java:</strong></p>
  
  <pre><code>[..]
  public static class FragmentPreferences extends PreferenceFragment {
          private Context context;
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              context = getActivity();
              PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false);
              addPreferencesFromResource(R.xml.preferences);
  
              final SharedPreferences sp = context.getSharedPreferences("PREFERENCE_KEY", Context.MODE_PRIVATE);
              SharedPreferences.OnSharedPreferenceChangeListener spChanged = new SharedPreferences.OnSharedPreferenceChangeListener() {
                  @Override
                  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                      context.finish();
                      startActivity(new Intent(ActivityPreferences.this, ActivityLogin.class));
                  }
              };
          }
      }
  </code></pre>
  
  <p>That's what I tried, but I can't call <code>finish()</code>.</p>
  
  <p>I want to change the theme, if the listpreference <code>s1_theme</code> has been set to light/dark:</p>
  
  <p><strong>ActivityMain.java:</strong></p>
  
  <pre><code>@Override
      protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          final Context context = getApplicationContext();
          final SharedPreferences sp = context.getSharedPreferences("PREFERENCE_KEY", Context.MODE_PRIVATE);
          if (sp.getString("s1_theme", "-1") == "light"){
                  setTheme(R.style.AppTheme_BaseLight);
          } else {
              setTheme(R.style.AppTheme_BaseDark);
          }
          setContentView(R.layout.activity_main);
          [..]
  </code></pre>