我想在移动设备中展示互联网的网络强度。
现在我可以检查来自 wifi 的连接或不使用下面的代码,但我还需要网络信号强度。所以请告诉我我需要添加什么代码?
谢谢!
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager
.getActiveNetworkInfo();
NetworkInfo mobNetInfo = connectivityManager
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
TextView netStatus = (TextView) findViewById(R.id.netStatus);
if (activeNetInfo != null) {
netStatus.setText(" Connection Status - Connected "+activeNetInfo.getTypeName());
} else if (mobNetInfo != null) {
netStatus.setText(" Connection Status - Connected "+mobNetInfo.getTypeName());
} else {
netStatus.setText(" Connection Status - Not Connected ");
}