System services , kotlin , android

Hello

how can I use system services in android using Kotlin :
take a look at this :

ConnectivityManager connec = (ConnectivityManager)getSystemService(getBaseContext().CONNECTIVITY_SERVICE);

I tried this :

val connec = getSystemService(getBaseContext().CONNECTIVITY_SERVICE) as ConnectivityManager

But there’s a problem with “CONNECTIVITY_SERVICE”

what did I miss?

In both Java and Kotlin You should use

Context.CONNECTIVITY_SERVICE 

instead of

getBaseContext().CONNECTIVITY_SERVICE