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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:49:50+00:00 2026-06-02T18:49:50+00:00

I read some similar questions (for example at this link ), but the problem

  • 0

I read some similar questions (for example at this link), but the problem I’m asking is a bit different. In fact, in my case the service is started manually by the startService method, then as a consequence it can not be started using the bindService method.

  1. Suppose we have a package that contains the MainService service and MainServiceActivity activity. In the file “AndroidManifest.xml” this activity is declared with action MAIN and category LAUNCHER. This activity is used to configure the service via the SharedPreferences and start the service by invoking startService method. In other words, typically the user launches the MainServiceActivity and configures/starts the MainService.
  2. Now consider another activity (Let’s call it SecondActivity) that is part of another package. Depending on the configuration, the service starts this activity using the startActivity method, so this other activity is running on a separate process than the MainService. As soon as the activity is running, it should inform the service.
  3. At this point, a communication request/reply begins between the MainService and the SecondActivity: the service sends a request and the activity sends a reply.

The communication via messaging might fit, but the MainService is started through startService method, so the bindService method can not be invoked by activities that want to bind to the service.

Then I had an idea that makes use of an additional service (Let’s call it UtilityService), which is part of the same package of MainService: the UtilityService could be started using the bindService method. As a consequence:

  • as soon as the MainService is running, it might perform the bind to the UtilityService;
  • when the MainService launches an external activity (for example the above SecondActivity), this activity bind to the UtilityService.

In this way, both the MainService and the SecondActivity are connected to the UtilityService, where the latter acts as an intermediary for communication.

Are there alternatives to this idea?

  • 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-02T18:49:52+00:00Added an answer on June 2, 2026 at 6:49 pm

    In fact, in my case the service is started manually by the startService method, then as a consequence it can not be started using the bindService method.

    You can both bind and start a service, if you wish. It’s a bit unusual, but it can be done.

    Are there alternatives to this idea?

    Binding has nothing in particular to do with services being able to communicate with activities. Using some sort of callback or listener object via binding is a possibility, but it is far from the only one.

    You can:

    • Have the service send a broadcast Intent, to be picked up by the activity

    • Have the activity send a PendingIntent (e.g., via createPendingResult()) to the service in an Intent extra on the command sent via startService(), to be used by the service to send information back to the activity (or wherever the activity wants it to go, such as a broadcast)

    • Have the activity pass a Messenger tied to its Handler to the service in an Intent extra on the command sent via startService(), to be used by the service to send information back to the activity

    All of those work perfectly well between processes, as well as within a process.

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

Sidebar

Related Questions

I've read some of the similar questions but they don't quite answer this query
I'm asking this question despite having read similar but not exactly what I want
Ok.. So Iknow there are some similar questions but I've read them and still
So I have read some of the similar asked questions, but I don't know
I have read some threads about this already but I don't understand the code,
I know there are similar questions to this one, but I haven't found any
Let me begin by saying this; I know that similar questions exist, but they
I have read through other questions on this site - using the example answer
I've seen some similar questions to mine here, but they don't really answer me...
Similar questions: Some characters in CSV file are not read during PHP fgetcsv() ,

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.