IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
Log.d("hbh", "onReceive: ================ net receive");
if (info != null && info.isAvailable()) {
int netType = info.getType();
if (netType == ConnectivityManager.TYPE_WIFI) {
int downCount = SharedPrefUtils.getInstance(context).getInt(Constants.DOWNLOAD_COUNT);
String updateStatus = SharedPrefUtils.getInstance(context).getString(Constants.UPDATE_STATUS);
Log.i("hbh", "onReceive connection wifi, has downCount = " + downCount + ", updateStaus = " + updateStatus);
if (Constants.UPDATE_STATUS_DOWNING.equals(updateStatus) && (downCount >= 4 && downCount <= 6)) {
}
} else if (netType == ConnectivityManager.TYPE_MOBILE) {
Log.i("hbh", "onReceive connection mobile data");
}
} else {
Log.e("hbh", "onReceive: no net");
}
网友评论