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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:58:54+00:00 2026-05-20T15:58:54+00:00

Stemming from this article more efficient way of updating UI from service I was

  • 0

Stemming from this article more efficient way of updating UI from service I was wondering if I could take that a step further and implement the following. I may have a misunderstanding of my Apps lifecycle though.

public class MyApplication extends Application {

    private static final String TAG = MyApplication.class.getSimpleName();
    private static Stack<MyActivity> mActivityStack = new Stack<MyActivity>();
    private static String mTopActivity = "none";

    public static void pushActivity(MyActivity activity)
    {
        mActivityStack.push(activity);
        mTopActivity = activity.getClass().getSimpleName();
        Log.i(TAG, "push::"+mTopActivity);
    }

    public static void popActivity()
    {
        Log.i(TAG, "pop::"+mTopActivity);
        mActivityStack.pop();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        Log.w(TAG, "low memory!!!");
        Log.w(TAG, "Current::"+mTopActivity);
    }
}

public class MyActivity extends Activity
{
    private static final String TAG = MyActivity.class.getSimpleName();

    public void onCreate(Bundle last)
    {
        super.onCreate(last);
        MyApplication.pushActivity(this);
    }

    public void onDestroy()
    {
        super.onDestroy();
        MyApplication.popActivity();
    }
}

Would the stack be valid during the lifecycle of the application?


As CommonsWare said, this did not work out. Also, it is not a great idea to derive from Activity, because you would then have to also derive listactivity, preferenceactivity, etc. Obviously, I did not think this would solve any problem it was just an experiment in android life cycles.

  • 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-20T15:58:54+00:00Added an answer on May 20, 2026 at 3:58 pm

    Would the stack be valid during the lifecycle of the application?

    Of course it won’t be valid. You assume every activity is created and destroyed in the same sequence. They won’t be in many cases (e.g., user presses HOME).

    Whatever problem you think you are solving this way, this is not the right solution by any stretch of the imagination.

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

Sidebar

Related Questions

This is a more direct question stemming from an earlier more general question i
This is a separate question stemming from this post: How to use the filename
Is there an easy way to simply exclude certain words from stemming in solr?
Stemming from this question of mine: I'm seeing artifacts when I attempt to rotate
stemming from this question This first image is with no overflow. The top is
This is stemming from a bad answer I gave last night. The curiosity as
Stemming from this question on using __get() and __set() to access private variables, I'd
I have stemming enabled in my Solr instance, I had assumed that in order
I am trying to use this code for the Porter stemming algorithm in a
I have a page that needs to be refreshed every 60 seconds. On this

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.