Skip to content

Latest commit

 

History

History
 
 

systemservices

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

System Services

No more context.getSystemService(NAME_OF_SERVICE) as NameOfManager.

Supported platforms: Android.

This library contains all the Android System Services as of API 29. It allows accessing them with a simple property.

Most System Services use the application Context and are available anywhere in the code of your app, but some that can vary depending on the Context (like LayoutInflater or WindowManager) are extensions on Context, View or AccessibilityService.

Example

Before:

fun performSomeVibration(vibe: VibrationEffect) {
    val vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
    vibrator.vibrate(vibe)
}

After:

fun performSomeVibration(vibe: VibrationEffect) {
    vibrator.vibrate(vibe)
}

Download

implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")