如果网络连接很慢,我必须显示一个页面
我正在使用此代码检查网络
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
if (info.getType() == ConnectivityManager.TYPE_WIFI) {
Toast.makeText(MainActivity.this,"wifi",Toast.LENGTH_LONG).show();
// do something
} else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
// check NetworkInfo subtype
if (info.getSubtype() == TelephonyManager.NETWORK_TYPE_GPRS) {
Toast.makeText(MainActivity.this,"mobile 100kbps",Toast.LENGTH_LONG).show();
// Bandwidth between 100 kbps and below
} else if (info.getSubtype() == TelephonyManager.NETWORK_TYPE_EDGE) {
Toast.makeText(MainActivity.this,"mobile 50-100kbps",Toast.LENGTH_LONG).show();
// Bandwidth between 50-100 kbps
} else if (info.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_0) {
Toast.makeText(MainActivity.this,"mobile 400-1000kbps",Toast.LENGTH_LONG).show();
// Bandwidth between 400-1000 kbps
} else if (info.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_A) {
Toast.makeText(MainActivity.this,"mobile 600-1400kbps",Toast.LENGTH_LONG).show();
// Bandwidth between 600-1400 kbps
}
它正在显示 wifi 网络但我需要慢速 wifi 网络的代码。请帮助我是否有任何代码可以检查慢速 wifi 网络。