答案 0 :(得分:2)
要获得 WiFi强度,您可以创建以下功能:
public static int calculateSignalLevel (int Rssi, int numLevels){
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numOfLevels);
}
如果要获取设备的状态以及是否已连接到互联网,可以使用以下功能:
public static String getConnectivityStatusString(Context context) {
int connected = NetworkUtil.getConnectivityStatus(context);
String wifiStatus = null;
if (connected == NetworkUtil.TYPE_WIFI) {
wifiStatus = "Wifi enabled";
} else if (connected == NetworkUtil.TYPE_MOBILE) {
wifiStatus = "Mobile data enabled";
} else if (connected == NetworkUtil.TYPE_NOT_CONNECTED) {
wifiStatus = "Not connected to Internet";
}
return wifiStatus;
}
最后,要获取电话提供商的名称,您可以使用以下功能:
public static String carrierName(){
TelephonyManager manager =(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.getNetworkOperatorName();
}
我希望这能回答您的问题。