Книга: Beginning Android

Manual Transmission

Manual Transmission

In addition to binding to the service for the purposes of IPC, you can manually start and stop the service. This is particularly useful in cases where you want the service to keep running independently of your activities — otherwise, once you unbind the service, your service could well be closed down.

To start a service, simply call startService(), providing two parameters:

1. The Intent specifying the service to start (again, the easiest way is probably to specify the service class, if it’s your own service)

2. A Bundle providing configuration data, which eventually gets passed to the service’s onStart() method

Conversely, to stop the service, call stopService() with the Intent you used in the corresponding startService() call.

Оглавление книги


Генерация: 1.468. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз