<@U6NNA1RPE>All an extension would do is exactly w...
# android
m
@ishitatsuyukiAll an extension would do is exactly what we're already doing manually, only hidden away. Does little to alleviate your type safety concerns, just makes it less verbose. How references to the system servicess are obtained is quite a rabbit hole and implemented very generically in the OS itself: https://stackoverflow.com/a/19925574. But I suppose you're right in that having a well written and tested set of extensions (maybe even properties) on the Context class, to access the common services, would at least make it less likely that you call
Copy code
getSystemService(Context.NOTIFICATION_SERVICE) as PowerManager
Although I don't know how common of a source of bugs something like this is. My guess: not very common. An extension would definitely be less ugly though.