Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:12:34+00:00 2026-06-14T11:12:34+00:00

I have 4 activities: Menu -> screen 1 Menu items -> screen 2 Detailed

  • 0

I have 4 activities:

Menu -> screen 1
Menu items -> screen 2
Detailed View -> screen 3
Ordered item -> screen 4

In Menu activity(screen 1) I have a button onclick of that it goes to MenuItems activity(scrren 2 which is List view), on click of any item in the list view it to corresponding item detailed view in this activity(screen 3) I have a button called ordered view, onlclick of this it would go to Ordered item(screen 4), in this scrren 4 I have a button which will go to screen 2.

This is the flow

Screen 1 ->screen 2->screen 3->screen 4->screen 2

Prob: after doing the basic flow now when I click on back in screen 2 it goes to screen 4 and again clicking on back it goes to screen 3 which is resulting the user to click back button n no of times since the activity already exists in stack.

How to handle this I mean back button navigation.

I have tried using flags in intent but it’s not working for me.

I have also referred this

  1. Android: Remove a series of Activites on clicking back

  2. On logout, clear Activity history stack, preventing "back" button from opening logged-in-only Activites

edit I got the answer:
so as few of my friends have answered here I used this
Intent.FLAG_ACTIVITY_CLEAR_TOP

So

screen 1->screen 2->screen 3-> screen 4->screen 2

So in screen 4 I have to set this flag so that it will clear all the activities above that activity.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:12:35+00:00Added an answer on June 14, 2026 at 11:12 am
    Intent intent= new Intent(this, screen 1.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Application have 5 activities(A1,A2,A3,A4,A5). Each activity have one text view and one button(B1,B2,B3,B4,B5).
I have an app that so far consists of two Activities: The Main Menu
I have a main activity (main menu / home screen) Most of my game
In my app I have a navigation menu that is constant between activities. To
In various activities I have very similar methods. For example: @Override public void onClick(View
I have 4 activities A, B, C and D. Activity A has a menu.
I have a menu that is always visible, and the same for all activities.
While extending a sample Android activity that fires some other activities from its menu,
I have 3 activities. 1st activity has a 'go right' image button. (to move
I have two activities with navigation menu which has items for launching Activity1 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.