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 6111701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:40+00:00 2026-05-23T14:39:40+00:00

Say I have 3 Activities in my application: A, B and C. The flow

  • 0

Say I have 3 Activities in my application: A, B and C. The flow though the application is: A -> B -> C.

Once at C, pressing the back button will take the user to B. If the user presses the back button another time they got to A, and finally if they press it one more time, they exit the application.

Objective: When the user presses the back button on C, they should go to A and not B, and if they press it another time, they exit the app.

Problem: When overriding the back button on Activity C to launch Activity A everything appears to be ok. However if the user presses the back button again, they return to Activity C. And so pressing the back button just switches between Activity A and Activity C.

I guess the Activity stack looks like:

  • Open app: A
  • Go to B: A, B
  • Go to C: A, B, C
  • Press back: A, B, C, A
  • Press back: A, B, C
  • Press back: A, B, C, A
  • Press back: A, B, C
  • Press back: A, B, C, A
  • Press back: A, B, C
  • Press back: A, B, C, A
  • …etc

So it seems the mistake is to launch a new Activity when the back button on C is pressed? Anyway, I could do with advice on how to implement this behaviour.

Thanks,
Jack

  • 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-05-23T14:39:40+00:00Added an answer on May 23, 2026 at 2:39 pm

    You can add finish() in the onStop() method of activity B.

    This way, when the activity B will no longer be visible, it will be destroyed and removed from the stack.

    • Open app: A
    • Go to B: A, B
    • Go to C: A, C
    • Press back: A
    • Press back: exiting
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirement I have an application with 2 activities, say A and B , with
I have an app that contains several activities...so lets say user is navigating activity
Say I have two Activities in an Android application, EditPerson and EditEmployee . It
I have an application with 4 or 5 activities! Let's say A, B, C,
Say we have two activities, Activity1 and Activity2. In Activity1's onClick() method, we have
Problem : I have say 4 activities A, B, C and D. A --
I am writing a application where I am dealing with 4 activities, let's say
I have 2 activities lets say A and B. In the first one(A) I
I have 5 activities (let's say A,B,C,D and E ). Activities A to D
In one of my Activities, I have multiple ListView controls. Say List 1 ,

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.