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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:36:29+00:00 2026-05-13T14:36:29+00:00

I currently have a Service that runs fine when I start it but when

  • 0

I currently have a Service that runs fine when I start it but when I try to stop it using the stopService method its onDestroy method doesn’t get called.

Here is the code I use to try to stop the Service

stop_Scan_Button = (Button)findViewById(R.id.stopScanButton);

stop_Scan_Button.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){
        Log.d("DEBUGSERVICE", "Stop Button pressed");
        Intent service = new Intent(CiceroEngine. CICERO_SERVICE);
        releaseBind();
        Log.d("Stop_Scan_Button", "Service: " + service.toString());
        stopService(service);
        Log.d("Stop_Scan_Button", "Service should stop! ");

        }   
});

Am I right in thinking that when stopService is used it calls the onDestroy method of the Service? When I press my stop scan button the onDestroy() method in my Service is not called.

Is there anything else I am missing that I should put in to stop the service?

EDIT: to add onServiceConnected() gets called when stopService is run instead of onServiceDisconnected(), why would that be happening?

EDIT:To add more info regards Binding

I call bindService in the onCreate() method and I then have the releaseBind() method unbind the Service.

Here is the code for that method:

 public void releaseBind(){
    unbindService(this);
  }

So I presume that the unbinding is not my problem?

  • 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-13T14:36:29+00:00Added an answer on May 13, 2026 at 2:36 pm

    I am going to guess that your having a method call for releaseBind() means that you previously called bindService() on this service and that releaseBind() is calling unbindService(). If my guess is incorrect, please ignore this answer.


    A service will shut down after all bindService() calls have had their corresponding unbindService() calls. If there are no bound clients, then the service will also need stopService() if and only if somebody called startService() on the service.

    So, there are a few possibilities here:

    1. You still have bound clients (e.g., other activities), in which case you cannot stop the service until they unbind
    2. Since both unbindService() and stopService() are asynchronous, something might be going haywire with the timing, in which case you may get better luck if you call stopService() from your ServiceConnection‘s onServiceDisconnected() method

    Also, bear in mind that the exact timing of the service being destroyed is up to Android and may not be immediate. So, for example, if you are relying upon onDestroy() to cause your service to stop some work that is being done, consider using another trigger for that (e.g., activity calling a stopDoingStuff() method through the service binder interface).

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

Sidebar

Related Questions

I have a windows service that runs fine, but I have to have it
I have a dotnet windows service that's currently hung, but running. Is there anyway
We currently have a production application that runs as a windows service. Many times
I currently have a streaming mediaplayer that runs in a service . Whenever I
I currently have a windows service that runs every 5 minutes. The code selects
We currently have an automated system that runs as a service for processing satellite
I currently have service classes that look something like this public class UserService :
I currently have a Service in Android that is a sample VOIP client so
We have an external service that is currently accessible via the http (port 80,
We have a C# Windows service that currently processes all the PDFs by reading

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.