Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Created March 23, 2018 18:40
Show Gist options
  • Save adrianhall/269280b52010dbdd20dbb7f11e85665f to your computer and use it in GitHub Desktop.
Save adrianhall/269280b52010dbdd20dbb7f11e85665f to your computer and use it in GitHub Desktop.
Extension function to pull the connectivityManager from the context
package com.amazon.aws.mobile.samples.tasks.extensions
import android.content.Context
import android.net.ConnectivityManager
/**
* Extension method to return the connectivity manager, given a context
*/
fun Context.getConnectivityManager(): ConnectivityManager {
return applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment