title: Android launches system settings instead of my app
body: <p>For some reason whenever I (try to) start my app the phone decides to launch system settings instead of my "main activity". And yes, I am referring to the "Android system settings", and not something from my app.</p>
  
  <p>This only happens on my phone, and I suppose it probably could be related to the fact that my app had just opened system settings when I decided to re-launch with a new version from Eclipse.</p>
  
  <p>It is possible to start the app from within Eclipse, but when I navigate back from the app it returns to the system settings rather than the home screen, as if the settings activity was started first and then my activity. If I then start the app from the phone all I get is system settings yet again.</p>
  
  <p>The app is listening to the VIEW-action for a specific URL substring, and when I start the app using a matching URL I get the same result as when I start it from Eclipse, app starts, but when I return I return to settings.</p>
  
  <p>I have tried googling for this problem, and all I could find was something about Android <a href="http://groups.google.com/group/android-developers/browse_thread/thread/68a101144b9660f9">saving state</a> when an app gets killed, but without any information on how to reset this state. I have tried uninstalling the app, killing system settings, rebooting the phone, reinstalling, clearing application data.. no luck..</p>
  
  <p>For what it's worth, here's the definition of my main activity from the manifest,</p>
  
  <pre><code>&lt;activity android:name=".HomeActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:clearTaskOnLaunch="true" android:launchMode="singleTop"&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;intent-filter&gt;
          &lt;action android:name="android.intent.action.VIEW"&gt;&lt;/action&gt;
          &lt;category android:name="android.intent.category.DEFAULT"&gt;&lt;/category&gt;
          &lt;category android:name="android.intent.category.BROWSABLE"&gt;&lt;/category&gt;
          &lt;data android:pathPrefix="/isak-web-mobile/smart/" android:scheme="http" android:host="*"&gt;&lt;/data&gt;
      &lt;/intent-filter&gt;
   &lt;/activity&gt;
  </code></pre>
  
  <p>And here is the logcat-line from when I try to start my app, nothing about any settings anywhere.</p>
  
  <pre><code>I/ActivityManager( 1301): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=se.opencare.isak/.HomeActivity }
  </code></pre>
  
  <p>When I launch from Eclipse I also get this line (as one would expect),</p>
  
  <pre><code>I/ActivityManager( 1301): Start proc se.opencare.isak for activity se.opencare.isak/.HomeActivity: pid=23068 uid=10163 gids={3003, 1007, 1015}
  </code></pre>
  
  <p>If it matters the phone is a HTC Desire Z running 2.2.1.</p>
  
  <p>Currently, this is my HomeActivity,</p>
  
  <pre><code>public class HomeActivity extends Activity {
      public static final String TAG = "HomeActivity";
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          Log.d(TAG, "onActivityResult(" + requestCode + ", " + resultCode + ", " + data + ")");
          super.onActivityResult(requestCode, resultCode, data);
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          Log.d(TAG, "onCreate(" + savedInstanceState + ")");
          super.onCreate(savedInstanceState);
      }
  
      @Override
      protected void onDestroy() {
          Log.d(TAG, "onDestroy()");
          super.onDestroy();
      }
  
      @Override
      protected void onPause() {
          Log.d(TAG, "onPause()");
          super.onPause();
      }
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          Log.d(TAG, "onPostCreate(" + savedInstanceState + ")");
          super.onPostCreate(savedInstanceState);
      }
  
      @Override
      protected void onPostResume() {
          Log.d(TAG, "onPostResume()");
          super.onPostResume();
      }
  
      @Override
      protected void onRestart() {
          Log.d(TAG, "onRestart()");
          super.onRestart();
      }
  
      @Override
      protected void onRestoreInstanceState(Bundle savedInstanceState) {
          Log.d(TAG, "onRestoreInstanceState(" + savedInstanceState + ")");
          super.onRestoreInstanceState(savedInstanceState);
      }
  
      @Override
      protected void onResume() {
          Log.d(TAG, "onResume()");
          super.onResume();
      }
  
      @Override
      protected void onStart() {
          Log.d(TAG, "onStart()");
          super.onStart();
      }
  
      @Override
      protected void onStop() {
          Log.d(TAG, "onStop()");
          super.onStop();
      }
  
      @Override
      protected void onUserLeaveHint() {
          Log.d(TAG, "onUserLeaveHint()");
          super.onUserLeaveHint();
      }
  }
  </code></pre>
  
  <p>Nothing (of the above) is written to the log.</p>
  
  <p>After reading Blundell's response I have tried changing the launchMode/clearTaskOnLaunch settings, with the following results,</p>
  
  <ul>
  <li>Situation A - I remove launchMode and clearTaskOnLaunch: same problem as before</li>
  <li>Situation B - I remove clearTaskOnLaunch and keeps launchMode="singleInstance": another problem
    <ul>
    <li>Open app - My HomeActivity is showing</li>
    <li>Click on a button to open another activity within my app - it opens as it should</li>
    <li>Click on the system back-button - it returns me to system settings</li>
    <li>Click on the system back-button again - I am returned to my HomeActivity</li>
    <li>Another click on the back-button brings me back to the Android home screen</li>
  </ul></li>
  <li>Situation C - I remove only launchMode and keeps clearTaskOnLaunch: same problem as before</li>
  <li>Sitatuion D - I remove clearTaskOnLaunch and set launchMode="singleInstance": same as situation B</li>
  </ul>