Cannot resolve getSystemService method in ListView adapter

后端 未结 8 1375
深忆病人
深忆病人 2021-01-25 00:23

I am working through John Horton\'s Android Programming for Beginners, and am currently attempting to create a note-taking app. Horton has just introduced ListVie

8条回答
  •  余生分开走
    2021-01-25 00:46

    mContext is Context which you pass to Custom Adapter

      public boolean CheckInternet() {
            ConnectivityManager connectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
                    connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
                //we are connected to a network
                return true;
            }
            return false;
        }//end of check internet
    

提交回复
热议问题