Here is one possibility: use ordered BroadcastReceivers with
android:priority attributes to determine which service is newest.

Each APK has its copy of the Service and a BroadcastReceiver.
The intent-filter for the BroadcastReceiver has the android:priority
attribute. Upon each release across all of these apps, you increment
the priority so that the newer the APK (and thus the service) the
higher the priority.

When you want to invoke a service, first use
Context.sendOrderedBroadcast to send an intent to the
BroadcastReceivers in the apps. The one with the highest priority will
be called first. You can then return to the caller an Intent to be
used to start the service in that APK.

Returning the Intent can be handled in one of two ways:
* Use BroadcastReceiver.setResultExtras() to store the Intent and
BroadcastReceiver.setResultCode to indicate that this has been
handled. All the other BRs along the way should check the ResultCode
to see if it has been set before responding themselves.  The last BR
in the chain would be the one supplied to the sendOrderedBroadcast()
function.
* Instead, you can pass a PendingIntent (such as from
Activity.createPendingResult()) in an Extra in the initial broadcast
intent. Then the first BR to receive the intent calls
BroadcastReceiver.abortBroadcast() to prevent the intent from going to
any of the older versions. The BR returns the service intent via the
PendingIntent.

-- 
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