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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:30:10+00:00 2026-05-17T20:30:10+00:00

I know my question caption must have sounded really vague. But let me clear

  • 0

I know my question caption must have sounded really vague. But let me clear it out here.

Say I have an android application over a middleware stack. In onCreate() of my activity, I initialise my middleware modules.

In its onDestroy(), I must de-initialise the middleware. Now my middleware calls may take quite some time to process. So I want to know how much time the onDestroy() function has, and see whether my deinitialisation can take place within that time.

Is it reasonable to keep my de-init in the onDestroy()?

Also, suppose I initialise the middleware in onCreate() of activity A1. On a button click, activity A1 switches to activity A2. In low memory situations, the LMK will kill the activity that has not been in use for some time. In such a case, won’t activity A1 be killed? When activity A1 is killed, will all instances I create in A1 also get destoryed?

Regards,
kiki

  • 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-17T20:30:11+00:00Added an answer on May 17, 2026 at 8:30 pm

    I believe you are rather confused to ask this question.

    In order to get a good comprehension of what is happening, you should take a look at the lifecycle graphs that can be found on developer.android.com:

    • Activity lifecycle
    • Background service lifecycle

    You will see that Activity.onDestroy() only gets called in the case of a controlled shutdown of the activity – something that happens extremely rarely, as the Android OS can kill your process in a variety of states without ever calling your onDestroy() method.

    What and why do you need to de-initialize?

    • If you’re worried about releasing resources, then most of them will get released anyway when/if your process is killed.
    • If you are worried about saving the user’s data (your application’s state) then you should override onSaveInstanceState() and onRestoreInstanceState()

    If you really want an answer to your question, then here it is:

    • While it is running onDestroy(), your app has (probably) as much time as it would like to – the fact that it is even running onDestroy() means that the OS did not select it to be killed. But it will most likely not matter: for one, onDestroy will never be run in most apps, and if the OS changes its mind and decides that your app must die, it will kill it even if it is running onDestroy.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been done but I have a slightly different twist
I know this question has been asked a few other times but I have
I know this question has been asked before, but I ran into a problem.
I know this question isn't directly programming related, but since I want to be
I know a question like this was already asked, but the situation is a
I know the question title isn't the best. Let me explain. I do a
I know this question has been asked a bit before. But looking around I
I know this question might sound a little cheesy but this is the first
I know this question is overly popular, but I find nothing that addresses rewriting
I know silly question but i tried looking it up on Google with no

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.