public static long current(Context context, String tag) {
        Long appRxValue = sReceivedBytes.get(tag);
        Long appTxValue = sSendBytes.get(tag);
        if (appRxValue == null || appTxValue == null) {
            if (DEBUG) {
                LogUtils.w(TAG, "current() appRxValue or appTxValue is null.");
            }
            return 0;
        }
        final int uid = getUid(context);
        long appRxValue2 = TrafficStats.getUidRxBytes(uid);
        long appTxValue2 = TrafficStats.getUidTxBytes(uid);
        long rxValue = appRxValue2 - appRxValue;
        long txValue = appTxValue2 - appTxValue;
        if (DEBUG) {
            LogUtils.v(TAG, "current() rxValue=" + rxValue / 1000 + " txValue=" + txValue / 1000 + " uid=" + uid);
        }
        return rxValue;

    }
public static long current ( Context context , String tag ) { Long appRxValue = sReceivedBytes . get ( tag ) ; Long appTxValue = sSendBytes . get ( tag ) ; if ( appRxValue == null || appTxValue == null ) { if ( DEBUG ) { LogUtils . w ( TAG , "current() appRxValue or appTxValue is null." ) ; } return 0 ; } final int uid = getUid ( context ) ; long appRxValue2 = TrafficStats . getUidRxBytes ( uid ) ; long appTxValue2 = TrafficStats . getUidTxBytes ( uid ) ; long rxValue = appRxValue2 - appRxValue ; long txValue = appTxValue2 - appTxValue ; if ( DEBUG ) { LogUtils . v ( TAG , "current() rxValue=" + rxValue / 1000 + " txValue=" + txValue / 1000 + " uid=" + uid ) ; } return rxValue ; }
计算当前流量

@param context Context
@param tag     traffic tag
@return received bytes