我愿意检测电话上的漫游开关是否已关闭。
if (Build.VERSION.SDK_INT < 17) {
isDataRoamingDisabled =
(Settings.System.getInt(context.getContentResolver(), Settings.Secure.DATA_ROAMING, 0)
== 0);
} else {
isDataRoamingDisabled =
(Settings.Global.getInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 0)
== 0);
}
不幸的是,仅对于 OnePlus One/Two/Three,该设置始终为 false (0)。在我测试过的其他设备上——Nexus 6P、LG G5、三星 S5 都运行良好……
telephonyManager.isNetworkRoaming(),
这里并不是真正的解决方案,因为它会检测用户是否处于漫游状态而不是切换设置。
感谢帮助!:)