Get signal strength of WIFI and Mobile Data
在我的应用中,我需要检查WiFi和移动数据的连接速度,然后进行比较,然后切换到速??度最快的网络。
-
那么如何获得wifi和移动设备的速度或最佳信号强度
数据? - 我该如何以编程方式关闭一个而另一个打开。
请帮帮我。
样本会有所帮助。
Wifi:
1 2 | WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE); int linkSpeed = wifiManager.getConnectionInfo().getRssi(); |
在移动设备上应该可以使用:
1 2 3 4 | TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); CellInfoGsm cellinfogsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0); CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength(); cellSignalStrengthGsm.getDbm(); |
然后您应该比较此信号电平,如果WIFI信号更好,请保持打开状态,但是如果手机更好,请断开wifi