1

I have an application design question

My intention is to have 3 intent services

1) A class based on GCMBaseIntentService

2) Web Registration Service - Register with a website

3) Data Refresh Service - Updates application data with latest data from a website

The GCM Service is used to register a new app installation with Google GCM if the device the app is installed on is capable of handling GCM. Both the WebRegistration and Data Refresh Services can be instantiated totally independently at appropriate times, on Application start up or in the case of the data refresh service at various points with the app and therefore it seems appropriate to have these as separate services.

Both the Web Registration Service and the Data Refresh Service should broadcast a message when they are done

On first time load of the app The GCM service needs to both register with the web server and update the applications data

Is it acceptable for the GCM Intent Service to register a broadcast receiver, fire off the Web registration intent service and when it receives a message in the broadcast receiver that this service is finished fire off the data refresh service?

If this approach is not acceptable I'd love to hear a more appropriate solution

4

2 回答 2

1

yes it is fine ... intentservices run as queues ... read the documentation at developer.android.com

于 2012-11-29T08:13:06.570 回答
1

You can call bindService from a Service exactly the same way you can call it from an Activity. You'll notice from the javadoc that the only place you can't call bindService is in a BroadcastReceiver. You can use a ServiceConnection as well to receive the Binder.

于 2012-11-29T08:14:12.977 回答