记录一次切换网络导致域名解析失败问题

2019-11-14  本文已影响0人  XBYoung

清空dns缓存

 private fun clearProcessBindNetWork() {
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                val connectivityManager = RearviewApplication.getmContext().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
                connectivityManager?.bindProcessToNetwork(null)
                return
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ConnectivityManager.setProcessDefaultNetwork(null)
                return
            }
        } catch (e: Throwable) {
            Log.e(TAG, e.message)
        }

    }
上一篇下一篇

猜你喜欢

热点阅读