systemService

inline fun <T> Context.systemService(): T

Return

a system service of type T.

This is a type-safe, concise alternative to getSystemService(Class), avoiding ::class.java shenanigans.

Example:

val statusBarManager = context.systemService<StatusBarManager>()

See also

Throws

if the service is not available on the device.