StrictMode java.lang.Throwable: Untagged socket detected

后端 未结 3 1367
陌清茗
陌清茗 2021-02-07 15:52

With StrictMode enabled I just started getting this exception:

java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to tra

3条回答
  •  天涯浪人
    2021-02-07 16:29

    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(
            StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .detectNetwork() // or .detectAll() for all detectable problems
                .detectAll() //                    .penaltyDeath()
                .penaltyLog()
                .build()
        )
        StrictMode.setVmPolicy(
            VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .detectAll()
                .penaltyLog() //                    .penaltyDeath()
                .build()
        )
    }
    

提交回复
热议问题