Listing 94 Stopping a Service Available for

downloadon ComponentName service = startService(new Intent(this, BaseballWatch.class));

Wrax.com // Stop a service using the service name.

stopService(new Intent(this, service.getClass()));

// Stop a service explicitly. try {

Class serviceClass = Class.forName(service.getClassName()); stopService(new Intent(this, serviceClass));

} catch (ClassNotFoundException e) {}

If startService is called on a Service that's already running, the Service'onStartCommand handler will be executed again. Calls to startService do not nest, so a single call to stopService will terminate it no matter how many times startService has been called.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment