Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
At this point, the example code has a complete implementation of a Service. Now we write code to control the service we previously defined.
Intent service = new Intent("com.androidbook.GPXService.SERVICE");
service.putExtra("update-rate", 5000);
startService(service);
Starting a service is as straightforward as creating an Intent with the service name and calling the startService() method. In this example, we also set the Intent extra parameter called update-rate to 5 seconds. That rate is quite frequent but works well for testing. For practical use, we probably want this set to 60 seconds or more. This code triggers a call to the onCreate() method, if the Service isn’t bound to or running already. It also triggers a call to the onStart() or onStartCommand() methods, even if the service is already running.