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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:25:30+00:00 2026-06-16T11:25:30+00:00

I read this great blog article Android Architecture Tutorial: Developing an App with a

  • 0

I read this great blog article Android Architecture Tutorial: Developing an App with a Background Service (using IPC)

The author show a tweet retrieving service running within a fixed interval in a separate process.

The service will keep running infinity. I realize to stop the process, going to Manage App and stop the service explicitly is the only way.

Note, this is not a very battery friendly way. Even the author claims himself.

Yes, there is a dark side to Android background services too – too
many services doing too much stuff in the background will slow down
the phone and suck the battery. However it’s not quite what I wanted
to bring up in this post, so maybe we’ll come back to resource
management etiquette in yet another post.

However, the author no longer update his blog.

I try to stop the service through TweetViewActivity.

@Override
protected void onDestroy() {
    super.onDestroy();              

    try {
        api.removeListener(collectorListener);
        unbindService(serviceConnection);
    } catch (Throwable t) {
        // catch any issues, typical for destroy routines
        // even if we failed to destroy something, we need to continue destroying
        Log.w(TAG, "Failed to unbind from the service", t);
    }

    // New code added by Cheok. Not working. Not sure why.
    this.stopService(intent);

    Log.i(TAG, "Activity destroyed");
}

But that doesn’t work. I can see the service still running. May I know, what is the correct way to stop the IPC service, once I quit the Activity? What is a good battery saving strategy for the above example?

  • 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-16T11:25:33+00:00Added an answer on June 16, 2026 at 11:25 am

    the reason it’s still running is because the system never called onDestroy.

    if you check this link: http://developer.android.com/reference/android/app/Activity.html you can see from the graph that the onDestroy is only called when the system is about to clear your application from the memory, and depending on the memory constrain it might never be called at all.

    The only callback that is guarantee to be called is onPause() and that’s the one you should rely on to stop your service.

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

Sidebar

Related Questions

I am using following a tutorial from here: http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/ This is the script I
I have read this great article by Mkyong about one-to-many relationship in Hibernate and
I just read this great answer from BalusC about how to upload files with
I have read Java Concurrency in Practice and this is a great reference, but
I read that great post on Visual Studio 2008 annoyances, but didn't see this
I read this post where the author advices to store session files in a
I read this article : http://lwuit.blogspot.in/2008/06/lightweight-text-input-in-lwuit.html This article talks of autocomplete textfield embedded on
I read this article on how to use keytool to generate CSRs for your
I have started using the Android StrictMode and find that it would be great
(A while back I read this great post: http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html , discussing the Rails CMS

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.