获取WIFI和移动数据的信号强度 [英] Get signal strength of WIFI and Mobile Data
本文介绍了获取WIFI和移动数据的信号强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序,我需要检查WiFi和移动数据的连接速度,然后进行比较,然后切换到以往的网络具有最高速度。
In my app I need to check the connection speed of both WiFi and Mobile Data and then compare it, then switch to which ever network has the highest speed.
- 所以,我怎么能得到的速度或WiFi和移动的最佳信号强度 数据?
- 我怎么能在编程开关一关等。
- So how can I get the speed or best signal strength of wifi and mobile data?
- how can I switch one off and other on programatically.
请帮助我。 样本将是有益的。
Please help me out. A sample would be helpful.
推荐答案
无线:
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
int linkSpeed = wifiManager.getConnectionInfo().getRssi();
在的情况下移动它应该工作:
In case of mobile it should work:
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
CellInfoGsm cellinfogsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
cellSignalStrengthGsm.getDbm();
那么你应该比较这信号电平,而如果WIFI信号好保持它打开,但如果手机更好断开无线网络
Then You should compare this signal levels and if WIFI signal is better keep it turn on, but if mobile is better disconnect wifi
这篇关于获取WIFI和移动数据的信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文