Re-launch of Activity on Home button, but...only the first time
<p>The application that I am developing has a weird behavior the first time that it is installed. If the user backs out of the application normally the first time, it will forever behave as it should.  If the user uses the home button the first time after installing the application, it treats the application as though it should re-launch the home screen again and launch a new version of an activity in front of the old one.</p>

<p>So there are really two issues at hand.  I can't seem to resolve both of them.</p>

<ol>
<li>Keep the application from closing when it is first installed upon the user hitting the home button.</li>
<li>Keep multiple versions of the application from launching when it does this (launchMode helps here a bit, but the first component still triggers).</li>
</ol>

<p>I don't have the <code>launchMode</code> attribute in the manifest file defined as anything.  So there shouldn't be any odd behavior as the result of this.  I have experimented now with the <code>launchmode</code> attribute of the application to see if I could get it to behave the way it is intended, but there seems to be more to it here than just launching the activities properly.  There is no reason that an application should close itself the first time as far as I can see when the home button is pressed.</p>

<p>I don't use the <code>onUserLeaveHint</code>  within the application either.  I had to be sure once again by doing a search over the project.  So there doesn't seem to be any overriding of the home button attempted at all.</p>

<p>Even after re-starting the phone, the home button behaves normally again.  Not sure what causes the initial installation to treat the home button as a flag to start the application from scratch.</p>

<p>Once the user backs out of the application the first time, the issue is permanently resolved.  Any thoughts on where I should look?</p>

<p>Recently there has been a search within the application to see if perhaps it triggers only then because of an <code>onUpgrade()</code> component of the SQLite database method causing some odd behavior.</p>

<pre><code>@Override
public void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
                if (newVersion &gt; oldVersion) {

           }
       }
</code></pre>

<p>Or in another location that might trigger with an update from the manifest file if I was passing along a newer version of the APK along to a device that had a version on it already that was one lower than the current one.  However, nothing in this part of the code leads me to believe that it should affect anything related to the launch sequence.</p>

<p>The manifest file (with names changed) is supplied below for what is currently being used in the application.  </p>

<p>
</p>

<pre><code>&lt;uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10"/&gt;

&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="com.android.vending.CHECK_LICENSE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.BLUETOOTH"/&gt;
&lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/&gt;

&lt;uses-permission android:name="android.permission.VIBRATE" android:required="false"/&gt;
&lt;uses-permission android:name="android.permission.CAMERA" android:required="false"/&gt;
&lt;uses-feature android:name="android.hardware.camera" android:required="false"/&gt;
&lt;uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/&gt;

&lt;application android:icon="@drawable/icon"
             android:label="@string/app_name"
             android:allowBackup="false"
             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
             &gt;
    &lt;activity android:name=".MyMain"
              android:label="@string/app_name_with_version"
              android:screenOrientation="portrait"
              android:windowSoftInputMode="adjustPan"   /&gt;
    &lt;activity android:name=".StartupActivity"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              &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;
    &lt;activity   android:name=".SelectActivity"  
                android:label="@string/app_name_with_version"
                android:screenOrientation="portrait"/&gt;
    &lt;activity   android:name=".ImageSelectionActivity"
                android:theme="@android:style/Theme.Dialog"
                android:label="@string/app_name_with_version"
                android:screenOrientation="portrait"
                android:configChanges="orientation|keyboardHidden"/&gt;            
    &lt;activity   android:name=".DetailsActivity"
                android:label="@string/app_name_with_version"
                android:screenOrientation="portrait"/&gt;
    &lt;activity   android:name=".EMailActivity"   
                android:label="@string/app_name_with_version"       
                android:screenOrientation="portrait"/&gt;
    &lt;activity   android:name=".SendTo" 
                android:label="@string/share_label" 
                android:theme="@android:style/Theme.Dialog" &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;ACTION android:name="android.intent.action.VIEW"&gt;  
                &lt;CATEGORY android:name="android.intent.category.DEFAULT"&gt;  
                    &lt;CATEGORY android:name="android.intent.category.BROWSABLE"&gt;  
                    &lt;DATA android:scheme="callback" android:host="twitter"/&gt;  
                    &lt;/CATEGORY&gt;  
                &lt;/CATEGORY&gt;
                &lt;/ACTION&gt;
            &lt;/INTENT-FILTER&gt;
            &lt;/ACTION&gt;
        &lt;/INTENT-FILTER&gt;
    &lt;/activity&gt;
    &lt;activity   android:name=".CreateMyActivity"
                android:label="@string/create_account_label"
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.Dialog"/&gt;
    &lt;activity   android:name=".ViewInLayoutActivity"
                android:label="@string/app_name_with_version"   
                android:screenOrientation="portrait"/&gt;
    &lt;activity   android:name=".Preferences"
                android:label="@string/set_preferences" 
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.Dialog"/&gt;
    &lt;activity   android:name=".AboutActivity"   
                android:label="@string/app_name_with_version"       
                android:screenOrientation="portrait"/&gt;
    &lt;activity   android:name=".InteractiveActivity" 
                android:label="@string/app_name_with_version"
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.Dialog"/&gt;   
    &lt;activity   android:name=".AlertFailedCommunications"
                android:screenOrientation="portrait"
                android:label="@string/alert_account_label"
                android:theme="@android:style/Theme.Dialog"/&gt;
&lt;/application&gt;    
</code></pre>

<p></p>
