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

  • SEARCH
  • Home
  • 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 7833909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:58:02+00:00 2026-06-02T12:58:02+00:00

Let’s say there’s an application that creates an account in AccountManager. User explores the

  • 0

Let’s say there’s an application that creates an account in AccountManager. User explores the quite complicated activity graph of this application for a while, then goes to Accounts and Sync in Android Settings, removes the account and signs in (still being in Accounts and Sync as a different user.

I have defined a receiver for LOGIN_ACCOUNTS_CHANGED broadcast and I’m able to shut down all services gracefully. But activities are still there, bearing the name of the first user in their header (UI gets messed up in a number of ways, but this one is the most obvious).

So, the question is: what should be done about these orphan activities?

  • I could use something like clearTaskOnLaunch, but all activities are in the background when the change happens.
  • Set a flag in SharedPreferences and check in onResume() of each activity, then launch clearTask activity if needed? Too messy.
  • The best option I was able to come up with is to use android.os.Process.killProcess(android.os.Process.myPid()) to kill all activities. This is not too graceful, but gets job done. The only side effect is that activity stack is still there, when the most reasonable thing seems to be to start from the LAUNCHER activity, with clear history.

So, what would be the best way to respond to the described scenario?

  • 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-02T12:58:04+00:00Added an answer on June 2, 2026 at 12:58 pm

    Have all your activities extend from a MyActivity class which has a BroadcastReceiver member: mChangeReceiver.

    Have MyActivity register mChangeReceiver in onCreate (and unregister in onDestroy), to the LOGIN_ACCOUNTS_CHANGED intent.

    Have the mChangeReceiver call some abstract method onAccountChanged() that all extending classes need to override and implement to reflect the change in the GUI.

    That’s it.
    Now, whenever the account changes, all your living activities will get their onAccountChanged method called and will refresh their GUI.

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

Sidebar

Related Questions

Let's say I have an facebook application running using the JS SDK. First user
Let's say there is a graph and some set of functions like: create-node ::
Let's say the Activity I want to start is named OccupyThePieShop I was previously
Let's say I have multiple requirements for a password. The first is that the
Let's assume that a user votes for some movies in a scale of 1
Let's say that I have a date in R and it's formatted as follows.
Let's say that I have a model that handles recipes, and I want to
Let's say a user is visiting my app website for the first time, so
Let's say that I have a set of relations that looks like this: relations
Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the

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.