tags:

views:

34

answers:

1

This app has multiple activities: eg: Activity1 -> Activity2 -> Activity3. If the app is opened after the Home button is used while in Activity2, the app returns to Activity2, but the desired functionality is for the app to always start with Activity1 from the launcher. Adding a finish() to the onStop() for Activity2 does cause app to start with Activity1 following use of the Home button, but then Activity3 causes the app to revert to Activity1 when it finishes, rather than Activity2, which is also undesirable. Is there a way to force the app to always start with Activity1 following use of the Home button?

public class Activity1 extends Activity {
    ...
    public void onCreate(Bundle savedInstanceState) {
        ...
        button1.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                startActivity(Activity2);
                ...

public class Activity2 extends Activity {
    ...
    private boolean applyMenuChoice(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menuItem1:
            startActivity(Activity3);
            ...
+1  A: 

You can configure this for your activity in your AndroidManifest.xml. I think the attribute you want is android:clearTaskOnLaunch.

You may want to check out what you can do with the activity element from the android dev guide.

InverseFalcon
android:clearTaskOnLaunch does *exactly* what is needed. Thank you very much.
JackN