Android Wifi 和数据(蜂窝)的 WorkManager 网络限制
Android WorkManager Network Constraint For Both Wifi and Data (Cellular)
我正在学习 WorkManager
并想知道是否遵循了为 Wifi 和数据(蜂窝)设置网络约束的正确方法:
val constraints = Constraints.Builder().run {
setRequiredNetworkType(NetworkType.UNMETERED) //Wifi
setRequiredNetworkType(NetworkType.METERED) //data
build()
}
这正是 NetworkType.CONNECTED
类型的用例:
Any working network connection is required for this work.
我正在学习 WorkManager
并想知道是否遵循了为 Wifi 和数据(蜂窝)设置网络约束的正确方法:
val constraints = Constraints.Builder().run {
setRequiredNetworkType(NetworkType.UNMETERED) //Wifi
setRequiredNetworkType(NetworkType.METERED) //data
build()
}
这正是 NetworkType.CONNECTED
类型的用例:
Any working network connection is required for this work.