Android Weekly Issue #410
Dark Mode: three Lint checks to help
夜间模式的Lint检查.
Connectivity State on Android 10 and Above
网络检查的API现在更新了.
不再使用CONNECTIVITY_ACTION
和NetworkInfo
了, 而要用: NetworkCallback
.
API 24+:
val cm = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
cm.registerDefaultNetworkCallback(ConnectivityCallback())
class ConnectivityCallback : NetworkCallback() {
override fun onCapabilitiesChanged(network: Network, capabilities: NetworkCapabilities) {
val connected = capabilities.hasCapability(NET_CAPABILITY_INTERNET)
notifyConnectedState(connected)
}
override fun onLost(network: Network) {
notifyConnectedState(false)
}
}
需要提供后向兼容.
Where Should I Put Kotlin Code in an Android Project?
Kotlin的代码到底应该放在哪里呢?
src/main/java
src/main/kotlin
Database Inspector
Android Studio 4.1将推出Database Inspector功能.
设备要求: API 26+.
Migrating to Material Components for Android
material-components-android是用来取代Design Support Library的.
本文具体讲怎么迁移到MDC 1.1.0.
Code
https://github.com/LukasLechnerDev/Kotlin-Coroutine-Use-Cases-on-Android
协程在Android中的实际应用示例.
网友评论