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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:12:44+00:00 2026-05-31T23:12:44+00:00

A service (S1) is bound in the constructor of a plain class C (i.e.

  • 0

A service (S1) is bound in the constructor of a “plain class” C (i.e. C does not have any lifecycle methods like (onCreate(), onDestroy() etc.) using an Intend. The context is provided on construction time in C’s constructor. C is instantiated by other services (Sx) using themselves as arguments for new C(context). in fact, that is eqivalent to using their respective contexts’ I guess.

Sx1 ->
      C -> S1
Sx2 ->

Question is: What’s the best method/location to unbind from S1?

  1. As there are no lifecycle methods in C, should I create an “artificial” onDestroy() method in C that is called once Sx’s onDestroy method is called? I dislike this a bit because I am lazy and might forget calling the onDestroy() method at some point in time as complexity grows.
  2. Or could I rely on the fact (don’t know if that really happens) that Android will manage a clean lifecycle and “automatically unbinds” from S1 once Sx or its context is destroyed?
  • 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-31T23:12:45+00:00Added an answer on May 31, 2026 at 11:12 pm

    A service (S1) is bound in the constructor of a “plain class” C

    Not really. Sx1 and Sx2 are binding to S1. They are responsible for those bindings. You just happen to have put the bindService() call in C, for whatever reason.

    What’s the best method/location to unbind from S1?

    Sx1 and Sx2 have to unbind from S1 when they are done with S1. Whether they unbind themselves or call a method on C to unbind, Sx1 and Sx2 are responsible for the bindings and therefore are responsible for unbinding.

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

Sidebar

Related Questions

I have an Activity and Service bound to it. If Service is killed by
I have successfully implemented a standard WCF service bound to MSMQ using the net.msmq
I'm writing a bound Service class for android. In addition, I thought I'd provide
I am trying to get the instance of a service class bound in jboss-service.xml
I have a service bound to an activity. The service will access a JSON
I've got an Activity and a service bound to it in the onCreate of
In my service, I have a protected constructor with @Inject and one of the
I have a service bound to an activity. The activity is a ListView of
I have a Service, which is foreground. It is locally bound to one (or
I have created a service class for my network connection so that my app

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.