代码
javanew(ct,"android.content.Context") javags(cs,ct,"android.content.Context","CONNECTIVITY_SERVICE") java(cm,activity,"android.app.Activity.getSystemService","String",cs) java(nif,cm,"android.net.ConnectivityManager.getActiveNetworkInfo") f(nif != null) { java(ss.rnink,nif,"android.net.NetworkInfo.isAvailable") tw("有网络") } else { ss rnink = false tw("无网络") }
本源码比hs获取网页判断是否有网络更加快速。