public final class

LocalServices

extends Object
java.lang.Object
   ↳ com.davidluoye.support.os.LocalServices

Class Overview

This class is used in a similar way as ServiceManager, except the services registered here are not Binder objects and are only available in the same process. Once all services are converted to the SystemService interface, this class can be absorbed into SystemServiceManager.

Summary

Public Methods
static <T> void addService(Class<T> type, T service)
Adds a service instance of the specified interface to the global registry of local services.
static <T> void addService(String name, T service)
Adds a service instance of the specified interface to the global registry of local services.
static <T> T getService(Class<T> type)
Returns a local service instance that implements the specified interface.
static <T> T getService(String name)
Returns a local service instance that implements the specified interface.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void addService (Class<T> type, T service)

Adds a service instance of the specified interface to the global registry of local services.

public static void addService (String name, T service)

Adds a service instance of the specified interface to the global registry of local services.

public static T getService (Class<T> type)

Returns a local service instance that implements the specified interface.

Parameters
type The type of service.
Returns
  • The service object.

public static T getService (String name)

Returns a local service instance that implements the specified interface.

Parameters
name The name of service.
Returns
  • The service object.