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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:26:18+00:00 2026-05-31T11:26:18+00:00

I created sample local service project as provided in Android Service article Extending the

  • 0

I created sample local service project as provided in Android Service article Extending the Binder class http://developer.android.com/guide/topics/fundamentals/bound-services.html.

Everything works fine. However the query is

With unbind(), service doesn’t get stopped. Should i need to use stopSelf() explicitly if yes than what does unbind() does.

I have create sample project with three buttons -> start, stop and fetch

start –> to bind service

stop –> to unbind service

start –> to access method of service. (random number generation method)

Now access to:

  1. start – binds the service

  2. fetch – gets access to method of service

  3. stop – unbinds the service

Here i excepted that service will be unbind and destroyed. However

Step 4: fetch – this method still works and generates random number whereas expected was some sort of exception or may be force close.

(onServiceDisconnected will not be called: since it will be called only in case of crash)

  • 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-31T11:26:19+00:00Added an answer on May 31, 2026 at 11:26 am

    For a remote service — where the service you bind to is in another process — attempting to call a method on the binder proxy after unbinding should result in a RemoteException.

    For a local service — where the service is still in your process — attempting to call a method on the binder after unbinding may still work. The binder in this case is the very same object that your service returned via onBind(). Garbage collection rules state that if you hold onto the binder, the binder cannot be garbage collected.

    However, calling methods on a binder after unbinding is dangerous and poor form. The service thinks it was destroyed. If there is anything your binder depends upon that the service cleaned up in onDestroy(), that might cause a crash. Similarly, you are leaking the service’s memory, until you allow the binder to be garbage collected.

    BTW, I hope your service is doing something more meaningful than “generates random number”. You do not need a service for that.

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

Sidebar

Related Questions

I am learning MVVM using sample created by Josh Smith at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx I wanted
I created a sample application using Android TextView with shared preferences . In my
I created a simple windows service on my local PC and added the following
I defined a local Service: public class ComService extends Service implements IComService { private
I ve created a sample REST web service which writes some data in a
I'm currently testing out retrieving json from jquery. The service url is: http://imgsvc.heroku.com/images In
I created sample rails app and deployed into heroku. Rails version is 3.1.3 Ruby
I wanted to learn something about Spring and Maven, so I created sample Maven
I created a sample webservice which contain default 'HelloWorld' function as 'webmethod' when tried
I have created a sample report with crystal report 10. Now, I wanna to

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.