4

As said here

When the user leaves a task by pressing the Home button, the current activity is stopped and its task goes into the background. <...> If the user later resumes the task by selecting the launcher icon that began the task, the task comes to the foreground and resumes the activity at the top of the stack.

So i prepared simple test

Activity #1 == text mark and button with onClick set

    public class FirstActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_layout);
    }

    public void onClick(View v)
    {
        Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
        startActivity(intent);
    }
}

Activity #2 == just text mark

    public class SecondActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second_layout);
    }
}

And manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10"/>
    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <activity android:name="FirstActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name="SecondActivity"
                  android:label="@string/app_name">
        </activity>

    </application>
</manifest>

Launcher icon does not show me last activity, it is always launchs first activity and put it into stack. So in one task there might be many first and many second activities. Icon from recent apps list launch exact last activity in stack. What am i doing wrong?

Community
  • 1
  • 1
mjollneer
  • 1,005
  • 2
  • 19
  • 36
  • 1
    There is an issue depending on how you are launching your app. If your start your app from your IDE when try this: please stop your application from options->applications. Then start your app from homescreen as usual users do. I expect in this case back stack behaviour would be normal – Robert Dec 04 '12 at 11:20
  • Indeed, it is. Thank you. But how is this possible? What's the difference? I read about this problem, but it seems to have eliminated in Eclipse long time ago. Apparently in Idea it still remained. In any case - certainly this is yet another joy of Android development. – mjollneer Dec 04 '12 at 11:47
  • I submited previous comment as answer. So if it helped you please mark is as answer to your question. And it could be closed. – Robert Dec 04 '12 at 11:56
  • 1
    @robert This problem not only occurs when you launch from IDE. It also occurs if you install or update the application via Google Play (Android Market) and also if you download the app via webbroswer or install it from the SD-card and then open it directly after installation from the INSTALLER screen. There are several open issues on the google code site for Android, but it seems the Android devs do not care :-( – David Wasser Jan 04 '13 at 13:07

1 Answers1

1

There is an issue depending on how you are launching your app. If your start your app from your IDE when try this: please stop your application from options->applications. Then start your app from homescreen as usual users do. I expect in this case back stack behaviour would be normal

Robert
  • 3,471
  • 3
  • 21
  • 24