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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:34:01+00:00 2026-06-05T12:34:01+00:00

I have an Android application. In one activity I start a service like this:

  • 0

I have an Android application.
In one activity I start a service like this:

Intent startIntent = new Intent(_context, HandlingService.class);
_context.startService(startIntent);

HandlingService is defined as follows:

public class HandlingService extends IntentService

Then inside HandlingService I have this:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, startId, startId);
    Log.v(ApplicationName,"HandlingService.onStartCommand");
    if ((flags & START_FLAG_RETRY) == 0){
        Log.v(ApplicationName,"Service is restarting");
    }
    return START_STICKY;
}

and this:

@Override
protected void onHandleIntent(Intent sourceIntent) {
    Log.v(ApplicationName, "HandlingService.onHandleIntent");
    sendSomething(); 
}

and lastly:

protected void sendSomething() {
    while (numberOfTry > 0) {
        numberOfTry++;
        Log.v(ApplicationName,"HandlingService.sending Something. Try# " + numberOfTry);
    }
}

numberOfTry starts in 1.

Then from the activity that starts the service, when I click on a cancel button I call this:

Intent stopIntent = new Intent(CallingActivity.this, HandlingService.class);
CallingActivity.this.stopService(stopIntent);

I see HandlingService.OnDestroy being called, but I keep seeing the log with “HandlingService.sending Something. Try# ” and the increasing numbers.

Question: Why it keeps alive if I already stopped it with the call to stopService?

Thanks in advance! Guillermo.

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

    The documentation for IntentService explicitly states that you should not override onStartCommand() in your derived class. You are probably messing up the internal mechanics of the IntentService.

    Either derive your class directly from Service or use the framework that IntentService already gives you (for starting/stopping itself).

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

Sidebar

Related Questions

I'm developing an Android application. On one activity I have a List with list
I am developing one application in android. In this I have to login into
i am new programmer in android application i would like display multiple notifications one
I have an android application that launches a child Activity under certain situations. Both
I have an Android application, backed by an API. To this API users can
can we have more than one application in android manifest.xml if so please provide
I have a menu in an Android application, and when I click one of
I am new in android and I have total 6-7 activities in my application.
I am working in android application.I have one doubt How long it takes to
In my manifest file, I have an activity declaration which looks something like 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.