StrictMode java.lang.Throwable: Untagged socket de

2019-04-12 13:45发布

问题:

With StrictMode enabled I just started getting this exception:

java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage

回答1:

My solution has been to call on initialisation the following:

private static final int THREAD_ID = 10000;
TrafficStats.setThreadStatsTag(THREAD_ID);