我想要的功能,
导入 android.telephony.TelephonyManager;
在颤振中,根据 pub.dev
包:flutter_android/android_telephony.dart
可以做同样的功能,但我无法让它工作。有人可以帮忙吗?
import android.telephony.TelephonyManager;
switch (info.getSubtype()) {
case TelephonyManager.NETWORK_TYPE_EDGE:
return "2G"; // ~ 50-100 kbps
case TelephonyManager.NETWORK_TYPE_HSDPA:
return "3G"; // ~ 2-14 Mbps
case TelephonyManager.NETWORK_TYPE_LTE:
return "4G"; // ~ 10+ Mbps
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
return "unknown"; // is connected but cannot tell the speed
default:
return "none";
}