title: Switching application-wide theme programmatically?
body: <p>I'm attempting to get a user-chosen theme and feel like I'm frustratingly close. Defining the theme in <code>AndroidManifest.xml</code> works as it should, but (as best I can tell) can't change based on app preferences:</p>
  
  <pre><code>&lt;application 
      android:theme="@style/theme_sunshine" 
      android:icon="@drawable/icon" 
      android:label="@string/app_name"&gt;
  </code></pre>
  
  <p>Alternatively, setting it dynamically in each activity also works:</p>
  
  <pre><code>someChosenTheme = PreferenceManager.getDefaultSharedPreferences(this).getString("themePreference", "theme_twilight");
  setTheme(someOtherChosenTheme);
  </code></pre>
  
  <p>But that seems messy, and I'd rather set the theme for the entire app in one place. My first thought was to grab the application context as soon as my main activity launches and do it there:</p>
  
  <pre><code>getApplicationContext().setTheme(R.style.theme_dummy);
  </code></pre>
  
  <p>As best I can tell, <a href="http://developer.android.com/reference/android/content/Context.html#setTheme%28int%29" rel="noreferrer">this</a> ought to do the trick, but in fact it's not doing anything - the entire app has the default Android style. Is the above valid, and if so, might I be doing something else dumb?</p>
  
  <p>I'm working in API level 3 if that matters. Prods in the right direction greatly appreciated!</p>
  
  <p><a href="https://stackoverflow.com/questions/3475207/multi-theme-support-in-android-app">Related question.</a></p>