首页 文章

获得WIFI和移动数据的信号强度

提问于
浏览
14

在我的应用程序中,我需要检查WiFi和移动数据的连接速度,然后比较它,然后切换到哪个网络具有最高的速度 .

  • 那么如何才能获得wifi和移动数据的速度或最佳信号强度?

  • 如何以编程方式关闭一个和另一个 .

请帮帮我 . 样本会有所帮助 .

1 回答

  • 31

    无线上网:

    WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
    int linkSpeed = wifiManager.getConnectionInfo().getRssi();
    

    如果是移动设备,它应该工作:

    TelephonyManager telephonyManager =        (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
    CellInfoGsm cellinfogsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0);
    CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
    cellSignalStrengthGsm.getDbm();
    

    然后你应该比较这个信号电平,如果WIFI信号更好保持它打开,但如果移动更好断开wifi

相关问题