美文网首页Android开发成长
Android Weekly Notes #410

Android Weekly Notes #410

作者: 圣骑士wind | 来源:发表于2020-04-20 13:11 被阅读0次

Android Weekly Issue #410

Dark Mode: three Lint checks to help

夜间模式的Lint检查.

Connectivity State on Android 10 and Above

网络检查的API现在更新了.

不再使用CONNECTIVITY_ACTIONNetworkInfo了, 而要用: 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中的实际应用示例.

相关文章

网友评论

    本文标题:Android Weekly Notes #410

    本文链接:https://www.haomeiwen.com/subject/vairihtx.html