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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:55:57+00:00 2026-06-17T07:55:57+00:00

I have a bug in my application I can’t figure out. There are three

  • 0

I have a bug in my application I can’t figure out. There are three activities: HomeActivity – A, TestActivity – B and ResultActivity – C.

Activity A launches B in a normal way

Intent intent = new Intent(this, TestActivity.class);
startActivity(intent);

Then activity B launches C in the same way. When C is done it goes back to A clearing the stack like this

Intent intent = new Intent(this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

Now the process can be repeated ad infinitum, without any issues. However, I have a shortcut that lets the user start B from C via A by sending a parameter to A intent.putExtra("startTest", true); which A uses to start B. Now what happens is if I press the back button, being in activity B, the activity gets restarted in stead of going back to A.

The activity stack seems to be just fine according to adb shell dumpsys activity:

Activity stack:
* TaskRecord{408276f0 #60 A com.company.app}
clearOnBackground=false numActivities=3 rootWasReset=true
affinity=com.company.app
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.company.app/.LoginActivity bnds=[120,241][240,391]}
realActivity=com.company.app/.LoginActivity
lastActiveTime=756688148 (inactive for 6s)
* Hist #12: HistoryRecord{40ab2248 com.company.app/.TestActivity}
    packageName=com.company.app processName=com.company.app
    launchedFromUid=10109 app=ProcessRecord{4089aed0 16527:com.company.app/10109}
    Intent { cmp=com.company.app/.TestActivity }
    frontOfTask=false task=TaskRecord{408276f0 #60 A com.company.app}
    taskAffinity=com.company.app
    realActivity=com.company.app/.TestActivity
    base=/data/app/com.company.app-1.apk/data/app/com.company.app-1.apk data=/data/data/com.company.app
    labelRes=0x0 icon=0x7f02000b theme=0x103000d
    stateNotNeeded=false componentSpecified=true isHomeActivity=false
    configuration={ scale=1.0 imsi=242/1 loc=nb_NO touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=22}
    launchFailed=false haveState=false icicle=null
    state=RESUMED stopped=false delayedResume=false finishing=false
    keysPaused=false inHistory=true launchMode=0
    fullscreen=true visible=true frozenBeforeDestroy=false thumbnailNeeded=false idle=true
    waitingVisible=false nowVisible=true
* Hist #11: HistoryRecord{40a548e8 com.company.app/.HomeActivity}
    packageName=com.company.app processName=com.company.app
    launchedFromUid=10109 app=ProcessRecord{4089aed0 16527:com.company.app/10109}
    Intent { flg=0x4000000 cmp=com.company.app/.HomeActivity }
    frontOfTask=false task=TaskRecord{408276f0 #60 A com.company.app}
    taskAffinity=com.company.app
    realActivity=com.company.app/.HomeActivity
    base=/data/app/com.company.app-1.apk/data/app/com.company.app-1.apk data=/data/data/com.company.app
    labelRes=0x0 icon=0x7f02000b theme=0x103000d
    stateNotNeeded=false componentSpecified=true isHomeActivity=false
    configuration={ scale=1.0 imsi=242/1 loc=nb_NO touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=22}
    launchFailed=false haveState=true icicle=Bundle[mParcelledData.dataSize=1192]
    state=STOPPED stopped=true delayedResume=false finishing=false
    keysPaused=false inHistory=true launchMode=0
    fullscreen=true visible=false frozenBeforeDestroy=false thumbnailNeeded=false idle=true

It doesn’t matter how many times I press the back button. The stack remains the same, and activity B keeps on restarting.

Now to the even stranger part: If i double tap the back button, it does indeed traverse back into the stack giving me activity A.

I don’t have any special handeling of the back button, and since it works well i case 1 but not case 2 I’m really lost. Searching hasen’t really got me anything, so any insight would be appreciated.

EDIT
Here are what I think are the relevant bits from the activities

  • HomeActivity.java
  • TestActivity.java
  • ResultActivity.java
  • 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-17T07:55:59+00:00Added an answer on June 17, 2026 at 7:55 am

    As you made normal scenario Complex. If You have use startActivityForResult() and onActivityResult() with necessary Flags and Conditions in your Activities then Above problems never occurs..

    Reason:

    As I have doubt when you press Back Button from B Activity its call repeatedly protected void onBackendStarted() of HomeActivity And your Activity B keep Restarting..

    Update:

    You have to remove startTest from Intent Once Activity B is started. So next Time it will not Launch Repeatedly.

    Something like:

    getIntent().removeExtra("startTest"); to onBackendStarted().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a bug in my app and I cannot figure it out.
I have a weird bug in my application that causes an activity to relaunch
I have a bug. In WinForm .NET2.0 application my HeavyFunction can be called from
I have an application in the market with a bug which I can not
We have a bug in our application that does not occur every time and
I have a very frustrating bug in an application I am working on. The
I have a strange bug in my Code Igniter application. When I call mysql_real_escape_string,
Today, I have come across a bug in my Zend Framework application. This is
I have this weird bug that I cannot fix. Can anyone help me? Thank
i have asp.net mvc application where my model has a relation like Question can

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.