title: Android: dynamically choosing a launch activity doesn't always work
body: <p>I've read a few articles here (and other places) that describe how to dynamically choose which activity to show when launching an app. Below is my code:</p>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;activity android:name=".StartupActivity"
            android:theme="@android:style/Theme.NoDisplay"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>StartupActivity.java</p>
  
  <pre><code>public class StartupActivity extends Activity
  {
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
  
          Intent intent;
          if (RandomClass.getSomeStaticBoolean())
          {
             intent = new Intent(this, ActivityOften.class);
          }
          else
          {
             intent = new Intent(this, ActivityRare.class);
          }
          startActivity(intent);
          finish();
      }
  }
  </code></pre>
  
  <p>Both ActivityOften and ActivityRare are declared in the manifest (without the launcher category of course) and extend ListActivity and Activity respectively. 99% of the time the 1st activity to get shown is ActivityOften based on RandomClass.getSomeStaticBoolean(). </p>
  
  <p>So launching my app from the icon for the 1st time I break inside the StartupActivity.onCreate. The choice is properly made. But then any subsequent attempts to launch the app (from a shortcut or the apps menu) show the ActivityOften again. No further breaks occur inside the StartupActivity class. Despite the fact that I know that RandomClass.getSomeStaticBoolean() has changed value and that ActivityRare should appear, the 1st activity keeps popping up.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks, Merci, Gracias, Danke, Grazie!
  Sean</p>