I'm sure that this will be a really newbie question but I'm stuck and I don't know how to get out of this!
I have an app that have three activities and when I use HOME button and I open the app again, it goes to the FIRST activity always, even if I was in the second or at the third one.
EDIT 3: My app comes in three activities, the first one is the main menu, the second is a map of tables and the third one are the data of the tables. Depending of the configuration, closing the third activity must bring me to the first one or the second one, and when I'm leaving the third Activity I dont want it to stay on the Activities stack. My program is working fine going from an Activity to another one. My problem is that seems that when I use Home Button my app finishes every Activity except the first one.
Maybe I have to modify anything on the manifest or maybe I have to use in a specifically way the RestoreInstanceState but I'm searching so hard and I can't find anything. Thanks in advance!
Edit 1: I'm adding my 'application' xml part of the Manifest:
<application
android:allowBackup="true"
android:icon="@drawable/icobaccus"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.example.tpv2_tablet.Activity_Start"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboardHidden|keyboard"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.tpv2_tablet.Activity_Zonas"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboardHidden|keyboard"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
<activity
android:name="com.example.tpv2_tablet.PrintDialogActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboardHidden|keyboard"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
<activity
android:name="com.example.tpv2_tablet.Activity_Mesas"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboardHidden|keyboard">
</activity>
</application>
Edit 2: Maybe I'm doing something wrong when calling other activities or I'm calling a wrong flag:
Intent intent = new Intent(Activity_1.this, Activity_2.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(intent);
Remove
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
from all activities
except launcher activity
To understand the reason why, read Google Documentation here
remove:
android:noHistory="true"
As this will remove the activity
from the activity stack
remove:
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
from:
Intent intent = new Intent(Activity_1.this, Activity_2.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(intent);
to understand the reason check this answer