I have a code to check if a user is connected
val connected:Boolean
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
connected = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_VPN).state == NetworkInfo.State.CONNECTED
if(connected){
} else {
}
but every time I build it tells me the its depreciated.
If there another way to check a user connectivity change please share.