Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; public class Main { private static ConnectivityManager getConnectivityManager(Context context) { // use application context to avoid leaking any activity // https://code.google.com/p/android/issues/detail?id=198852 return (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); } }