de.unikassel.android.sdcframework.service
Class ServiceUtils

Package class diagram package ServiceUtils
java.lang.Object
  extended by de.unikassel.android.sdcframework.service.ServiceUtils

public class ServiceUtils
extends Object

Service utility class providing a test function to check for a running services instance.


Constructor Summary
ServiceUtils()
           
 
Method Summary
static String getResolvedClassForService(Context context, Class<?> serviceClass)
          Method to test for the availability of the SDC service
static boolean isServiceAvailable(Context context, Class<?> serviceClass)
          Method to test for the availability of a service
static boolean isServiceRunning(Context applicationContext, Class<?> serviceClass)
          Method to test for a running service by class.
private static boolean isServiceRunning(Context applicationContext, String serviceClassName)
          Method to test for a running service by class name.
static ComponentName startService(Context applicationContext, Class<?> serviceClass)
          Method to start a service
static ComponentName startService(Context applicationContext, String serviceClassName)
          Method to start a service by name (e.g.
static boolean stopService(Context applicationContext, Class<?> serviceClass)
          Method to stop a running service
static boolean stopService(Context applicationContext, String serviceClassName)
          Method to stop a service by name (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceUtils

public ServiceUtils()
Method Detail

isServiceRunning

public static boolean isServiceRunning(Context applicationContext,
                                       Class<?> serviceClass)
Method to test for a running service by class.

Parameters:
applicationContext - the application context
serviceClass - the service to test for
Returns:
true if the service is running, false otherwise

isServiceRunning

private static boolean isServiceRunning(Context applicationContext,
                                        String serviceClassName)
Method to test for a running service by class name.

Parameters:
applicationContext - the application context
serviceClassName - the name of the service class to test for
Returns:
true if the service is running, false otherwise

isServiceAvailable

public static boolean isServiceAvailable(Context context,
                                         Class<?> serviceClass)
Method to test for the availability of a service

Parameters:
context - the context to use
serviceClass - the service class
Returns:
true if intent can be called

getResolvedClassForService

public static String getResolvedClassForService(Context context,
                                                Class<?> serviceClass)
Method to test for the availability of the SDC service

Parameters:
context - the context to use
serviceClass - the service class
Returns:
true if intent can be called

stopService

public static boolean stopService(Context applicationContext,
                                  Class<?> serviceClass)
Method to stop a running service

Parameters:
applicationContext - the application context
serviceClass - the class of the service to stop
Returns:
true if successful, false otherwise

stopService

public static boolean stopService(Context applicationContext,
                                  String serviceClassName)
Method to stop a service by name (e.g. using the interface class name )

Parameters:
applicationContext - the application context
serviceClassName - the class name of the service to stop
Returns:
true if successful, false otherwise

startService

public static ComponentName startService(Context applicationContext,
                                         Class<?> serviceClass)
Method to start a service

Parameters:
applicationContext - the application context
serviceClass - the class of the service to start
Returns:
If the service is being started or is already running, the ComponentName of the actual service that was started is returned; else if the service does not exist null is returned.

startService

public static ComponentName startService(Context applicationContext,
                                         String serviceClassName)
Method to start a service by name (e.g. using the interface class name )

Parameters:
applicationContext - the application context
serviceClassName - the class name of the service to start
Returns:
If the service is being started or is already running, the ComponentName of the actual service that was started is returned; else if the service does not exist null is returned.