Why the lines are crossed out and the error

Why the lines are crossed out and the error where the dot is I don't understand

package com.ggenius.whattowearkotlin.data.network

import android.content.Context
import android.net.ConnectivityManager
import com.ggenius.whattowearkotlin.internal.NoConnectivityException
import okhttp3.Interceptor
import okhttp3.Response

class ConnectivityInterceptorImpl(
    context: Context?
) : ConnectivityInterceptor {

    private val appContext = context.applicationContext

    override fun intercept(chain: Interceptor.Chain): Response {
        if (!isOnline())
            throw NoConnectivityException()
        return chain.proceed(chain.request())
    }

    private fun isOnline() : Boolean {
        val connectivityManager = appContext.getSystemService(Context.CONNECTIVITY_SERVICE)
        as ConnectivityManager
        val networkInfo = connectivityManager.activeNetworkInfo
        return networkInfo != null && networkInfo.isConnected
    }
}

Check screenshot enter image description here


Solution 1:

This line is crossed out

val networkInfo = connectivityManager.activeNetworkInfo

Because the getActiveNetworkInfo() method is deprecated according to their API

https://developer.android.com/reference/android/net/ConnectivityManager#getActiveNetworkInfo()