On 11/23/2010 10:01 PM, Biosopher wrote:
> We are providing an Android Service to multiple customers for
> packaging into their .apks and need to ensure that only a single
> instance of our Service is running at a time.  The ideal situation
> would be this:
> 
> When one of our customers's apps is installed on a device, it looks
> for instances of our Service. If our service is not present, our
> customer's app would install our Service.  If our Service was present,
> the customer's app would use the existing Service.  If the currently
> installed Service was an older version, our customer's app would
> upgrade the current Service with the newer one.
> 
> We are pursuing a Shared Library solution, but this introduces many
> extra issues: access to resources, declaration of our Services in the
> customer manifest, ....  Instead, we prefer to provide our customers
> with an .apk that would be optionally installed.

An external apk isn't a good idea IMO, as discussed on the android-ndk group.

I think that you may embed the service in each app, but still manage to have
only one instance of the service running most of time.

A given service can be accessed by any other app by declaring proper
permissions. Therefore app A can use the service embedded in app B.

By using intent filters, possibly coupled with content providers, you may also
have each app discover how many such services are installed and their respective
version.

So if app A needs the service v2, it could check if a such service is already
installed and running, if yes bind it. Otherwise, start its own service. If the
service v1 is also running and used by app B, then that would result in two
services running at the same time, yes.

But if the user is properly upgrading its applications then the version of all
installed services should match, I guess. And if you don't release a new version
of the service often, it should be ok. In this idea, the service version and app
versions would be independent of each other.

There might be couple of concurrency/race issues, but I think it can be solved.

-- 
  Olivier

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to