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
.
Before:
fun performSomeVibration(vibe: VibrationEffect) {
val vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(vibe)
}
After:
fun performSomeVibration(vibe: VibrationEffect) {
vibrator.vibrate(vibe)
}
implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")