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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:11:20+00:00 2026-05-20T03:11:20+00:00

I have a Service that is supposed to maintain a constant connection with a

  • 0

I have a Service that is supposed to maintain a constant connection with a home automation controller (HAC). In the preferences of the App, I will give the User a choice to stay** connected to the HAC or to drop the connection to the HAC when the App is not in use. I intend to use startService(), with a look at the preferences to see if it’s necessary to call stopSelf() from within the Service.

I basically have two questions:

  1. Is it necessary to Bind to the service from every Activity in the App? (I’m finding that the onBind() doesn’t seem to execute after my SplashScreen Activity has started and binded to the Service). I even commented out the call to bindService() from an Activity and I’m still able to use the calls the Service. I was hoping to use the onBind() callback to verify if the Service still has a valid connection to the HAC.

  2. If I use startService(), and then bindService(); will unBindService() then allow the service to stop if there are no other objects bound? Also, if I start the service with bindService() and then subsequently call startService(); what happens? I’m trying to understand how these two approaches to interacting with the Service affect the lifecycle.

Thanks,
J

** I realize this can be detrimental to battery life, but sometimes it’s nice when the NotificationManager tells you that the Motion Detector on your front porch has just been tripped.

  • 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-20T03:11:21+00:00Added an answer on May 20, 2026 at 3:11 am

    I have a Service that is supposed to maintain a constant connection with a home automation controller (HAC). In the preferences of the App, I will give the User a choice to stay** connected to the HAC or to drop the connection to the HAC when the App is not in use. I intend to use startService(), with a look at the preferences to see if it’s necessary to call stopSelf() from within the Service.

    This is a refreshingly rational and sensible approach — let the user control how her device is being used. Kudos!

    Is it necessary to Bind to the service from every Activity in the App?

    It is not necessary to bind to the service from any activity in the app, if you are using startService() to start it.

    I was hoping to use the onBind() callback to verify if the Service still has a valid connection to the HAC.

    Particularly for lightweight, read-only, not-likely-to-cause-GC-issues stuff like a connection status, I’d just stick it in a static data member. Now, if you need a more complex API than that, then you’ll need binding, but binding is a pain in various body parts when it comes to configuration changes (e.g., screen rotations).

    If I use startService(), and then bindService(); will unBindService() then allow the service to stop if there are no other objects bound?

    No, the startService() will keep it around, regardless of unbindService().

    Also, if I start the service with bindService() and then subsequently call startService(); what happens?

    Ummm…can you be more specific? I mean, I feel reasonably comfortable in saying that your sequence of events will not cause a rupture in the space-time continuum, nor will it cause me to spontaneously grow hair. 🙂

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

Sidebar

Related Questions

I have a service that will return 0 or more sets of data. The
I have a silverlight library that is supposed to get make a web service
I have a windows service that is supposed to send e-mails periodically. Next to
I have a WCF service that supposed to provide service to several clients. The
Suppose I had a WCF service that I have coded up, like Clemens Vasters's
I have a service that I would like it to become single instance, because
I have a service that is downloading a file. When the download is done,
I have .Net service that listens on single port over TCP protocol. Clients connect
I have a service that needs to update the registry every 5 minutes (counteract
I have a service that has a dependency on SQL server express (2005). Every

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.