I developed one application in android.It works perfectly but if i press back button then it will show all the previous activities like currently login,previous login etc. means all the things. How this remove from?
Asked
Active
Viewed 99 times
0
-
Try this: finish() current activity while going to next activity. – Raghavendra Sep 02 '16 at 13:19
-
1This link will help you to how to maintain stack(not session) in application: https://developer.android.com/guide/components/tasks-and-back-stack.html – YLS Sep 02 '16 at 13:20
-
Possible duplicate of [Android: Preventing going back to the previous activity](http://stackoverflow.com/questions/8631095/android-preventing-going-back-to-the-previous-activity) – Douglas Nassif Roma Junior Sep 02 '16 at 14:42
3 Answers
1
Use finish()
after Intent calling for next activity.
for example..
Intent intent = new Intent(YourActivity.this, NextActivity.class);
startActivity(intent);
finish();
It open next activity and remove activity from BackStackTrace.

Jitesh Prajapati
- 2,533
- 4
- 29
- 51
0
call finish() before starting the next activity

Awais Ahmad
- 427
- 3
- 17
-
okay. i will try it. firstly i was tried it. but not working. so... but now i will also try this time.thank you so much. – Poonam Desai Sep 13 '16 at 10:00
0
call finish()
after Intent calling for next activity.
/
Providing Proper Back Navigation
https://developer.android.com/training/implementing-navigation/temporal.html
For example:
<application ... >
...
<!-- The main/home activity (it has no parent activity) -->
<activity
android:name="com.example.myfirstapp.MainActivity" ...>
...
</activity>
<!-- A child of the main activity -->
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>

nzala
- 374
- 4
- 10