Providing a background service for other applications

I am new to Android development and I could not find it in the Developer's Guide.

I would like to create a background service so that any other application can connect to it and get some data from it. I saw android.app.Service, but it seems that it allows other applications to ping the service, but it does not allow them to register for certain events. I meant something like the built-in LocationManager and its addProximityAlert or even requestLocationUpdates.

Is this possible with existing sdk?

+5
android service
source share
2 answers

perhaps this sample might help you: RemoteService .

This is a description from the Android developer site:

Remote Controller and Removal Service Binding Demonstrates starting a service in a separate process by assigning android: process = ": remote" to the service in the AndroidManifest.xml file. Shows how these clients can either start / stop it using {@link android.content.Context # StartService Context.startService} and {@link android.content.Context # StopService Context.stopService} or bind and call it with {@ link android.content.Context # bindService Context.bindService} and {@link android.content.Context # unbindService Context.unindService}. The binding is similar to the local service model, but illustrates the additional work (defining auxiliary interfaces) needed to interact with the service in another process. It also shows how a service can publish multiple interfaces and implement callbacks for its clients.

+1
source share

Hello and welcome the development of Android. I hope you enjoy your stay: D. About your question:

What you ask is done with Service . If you want applications to register for events, which is usually done, this is the following:

  • Create a service with all the logic.
  • Make the service send Broadcast messages.
  • All interested applications will receive a recipient class to receive this message.

I would like to know what you are trying to do to provide you further assistance.

+1
source share

All Articles