当前位置: 首页>>代码示例>>Java>>正文


Java TrafficStats.getTotalTxBytes方法代码示例

本文整理汇总了Java中android.net.TrafficStats.getTotalTxBytes方法的典型用法代码示例。如果您正苦于以下问题:Java TrafficStats.getTotalTxBytes方法的具体用法?Java TrafficStats.getTotalTxBytes怎么用?Java TrafficStats.getTotalTxBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.TrafficStats的用法示例。


在下文中一共展示了TrafficStats.getTotalTxBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_traffic);
	
	//��ȡ�ֻ���������
	//��ȡ����(R �ֻ�(2G,3G,4G)��������)
	long mobileRxBytes = TrafficStats.getMobileRxBytes();
	//��ȡ�ֻ���������(�ϴ�+����)
	//T total(�ֻ�(2G,3G,4G)������(�ϴ�+����))
	long mobileTxBytes = TrafficStats.getMobileTxBytes();
	//total(���������ܺ�(�ֻ�+wifi))
	long totalRxBytes = TrafficStats.getTotalRxBytes();
	//(������(�ֻ�+wifi),(�ϴ�+����))
	long totalTxBytes = TrafficStats.getTotalTxBytes();
	
	//���岻��
	//������ȡģ��(���Ͷ���),��Ӫ��(��ͨ,�ƶ�....),(��������)�������ӿ�,���
	//����ע��
	
	
	
}
 
开发者ID:cckevincyh,项目名称:mobilesafe,代码行数:24,代码来源:TrafficActivity.java

示例2: initData

import android.net.TrafficStats; //导入方法依赖的package包/类
/**
 * init data
 */
@Override
protected void initData() {
    long totalRxBytes = TrafficStats.getTotalRxBytes();
    long totalTxBytes = TrafficStats.getTotalTxBytes();
    long mobileRxBytes = TrafficStats.getMobileRxBytes();
    long mobileTxBytes = TrafficStats.getMobileTxBytes();

    long totalBytes = totalRxBytes + totalTxBytes;
    long mobileBytes = mobileRxBytes + mobileTxBytes;

    tvTotalTrafficStatsSum.setText(getString(R.string.total_traffic_stats_sum, Formatter.formatFileSize(this, totalBytes)));
    tvMobileTrafficStatsSum.setText(getString(R.string.mobile_traffic_stats_sum, Formatter.formatFileSize(this, mobileBytes)));
    tvTotalTrafficStats.setText(getString(R.string.traffic_stats_upload_download, Formatter.formatFileSize(this, totalTxBytes), Formatter.formatFileSize(this, totalRxBytes)));
    tvMobileTrafficStats.setText(getString(R.string.traffic_stats_upload_download, Formatter.formatFileSize(this, mobileTxBytes), Formatter.formatFileSize(this, mobileRxBytes)));

}
 
开发者ID:ittianyu,项目名称:MobileGuard,代码行数:20,代码来源:TrafficStatsActivity.java

示例3: dataThrougput

import android.net.TrafficStats; //导入方法依赖的package包/类
public void dataThrougput() {
	synchronized(this) {
		totalRxBytes = TrafficStats.getTotalRxBytes();		
		totalTxBytes = TrafficStats.getTotalTxBytes();		
		if (dataActivityRunnable.hasDataActivity == 0) {
			//dataActivityRunnable.initializeHasDataActivity(1);
			dataActivityRunnable.init(totalRxBytes, totalTxBytes, true);
		}	
		else if (dataActivityRunnable.hasDataActivity == 1)
		{
			//MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "onDataActivity", "in sampling");
		}
		else if (dataActivityRunnable.hasDataActivity == 2)
		{
			//MMCLogger.logToFile(MMCLogger.Level.DEBUG, TAG, "onDataActivity", "already in download");
		}
	}
}
 
开发者ID:RestComm,项目名称:android-QoS,代码行数:19,代码来源:LibPhoneStateListener.java

示例4: updateSignalStrength

import android.net.TrafficStats; //导入方法依赖的package包/类
/**
 * This method sends the signal strength update to all listeners of the signal strength update action.
 * This update includes the absolute signal strength (in dbm) and the percentage it has been assigned.
 * @param signalStrength
 */
public void updateSignalStrength(int signalStrength, int nettype, boolean bWifiConnected, int wifiSignal){
	Intent intent = new Intent(CommonIntentBundleKeysOld.ACTION_SIGNAL_STRENGTH_UPDATE);
	intent.putExtra(CommonIntentBundleKeysOld.KEY_UPDATE_SIGNAL_STRENGTH_DBM, signalStrength);
	intent.putExtra(CommonIntentBundleKeysOld.KEY_UPDATE_NETTYPE, nettype);

	//if (owner.wsConnected) {
		long totalRxBytes = TrafficStats.getTotalRxBytes();
		long totalTxBytes = TrafficStats.getTotalTxBytes();
		intent.putExtra(CommonIntentBundleKeysOld.KEY_RX, totalRxBytes);
		intent.putExtra(CommonIntentBundleKeysOld.KEY_TX, totalTxBytes);
	intent.putExtra(CommonIntentBundleKeysOld.KEY_WIFI_CONNECTED, bWifiConnected);
	intent.putExtra(CommonIntentBundleKeysOld.KEY_WIFI_SIGNAL, wifiSignal);


	//}

	owner.sendBroadcast(intent);
}
 
开发者ID:RestComm,项目名称:android-QoS,代码行数:24,代码来源:IntentDispatcher.java

示例5: updateRxTx

import android.net.TrafficStats; //导入方法依赖的package包/类
public void updateRxTx ()
{
	if (lastRxTxUpdate + 4000 < System.currentTimeMillis())
	{
		// Update Neighbor list history if state changes
		long rx = TrafficStats.getTotalRxBytes();
		long tx = TrafficStats.getTotalTxBytes();
		tcpstats.readTcpStats(false);
		tcpstats.updateCounts();
		int tcprsts = tcpstats.tcpResets;
		int tcperrs = tcpstats.tcpErrors;
		int tcpretrans = tcpstats.tcpRetrans;

		if (rx > rxLast + 10000 || tx > txLast + 10000 || tcpstats.tcpResets > tcpstats.prevResets || tcpstats.tcpErrors > tcpstats.prevErrors || tcpstats.tcpRetrans > tcpstats.prevRetrans) {
			ConnectionSample smp2 = new ConnectionSample(TYPE_RXTX, rx, tx, tcprsts, tcperrs, tcpretrans);
			rxLast = rx; txLast = tx;
			connect_history.add(smp2);
		}
		lastRxTxUpdate = System.currentTimeMillis();
	}
}
 
开发者ID:RestComm,项目名称:android-QoS,代码行数:22,代码来源:ConnectionHistory.java

示例6: handleMessage

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
public boolean handleMessage(Message msg) {

    //不准?...

    long mrx = TrafficStats.getMobileRxBytes() / 1024; ////获取通过Mobile连接收到的字节总数,不包含WiFi
    long mtx = TrafficStats.getMobileTxBytes() / 1024; //Mobile发送的总字节数
    long trx = (long) ((TrafficStats.getTotalRxBytes() - mTotalRxBytes) * 1.00f / 1024);
    mTotalRxBytes = TrafficStats.getTotalRxBytes(); //获取总的接受字节数,包含Mobile和WiFi等
    long ttx = TrafficStats.getTotalTxBytes() / 1024; //总的发送字节数,包含Mobile和WiFi等
    long uidrx = TrafficStats.getUidRxBytes(getApplicationInfo().uid) / 1024;//获取某个网络UID的接受字节数,某一个进程的总接收量
    long uidtx = TrafficStats.getUidTxBytes(getApplicationInfo().uid) / 1024;//获取某个网络UID的发送字节数,某一个进程的总发送量
    StringBuilder sb = new StringBuilder();

    sb.append("mrx:" + mrx + "\n\r")
            .append("mtx:" + mtx + "\n\r")
            .append("trx:" + trx + "\n\r")
            .append("ttx:" + ttx + "\n\r")
            .append("uidrx:" + uidrx + "\n\r")
            .append("uidtx:" + uidtx + "\n\r")
    ;
    mTvDeviceInfo.setText(sb.toString());
    mHandler.sendEmptyMessageDelayed(0, 1000);

    return true;
}
 
开发者ID:AlanCheen,项目名称:PracticeDemo,代码行数:27,代码来源:DeviceInfoActivty.java

示例7: getTraffic

import android.net.TrafficStats; //导入方法依赖的package包/类
public static HashMap<String, Long> getTraffic() {
    HashMap<String, Long> hashMap = new HashMap<>();

    long mobileRxBytes = TrafficStats.getMobileRxBytes();
    long mobileTxBytes = TrafficStats.getMobileTxBytes();
    long totalRxBytes = TrafficStats.getTotalRxBytes();
    long totalTxbytes = TrafficStats.getTotalTxBytes();

    long wifiRxbytes = totalRxBytes - mobileRxBytes;
    long wifiTxbytes = totalTxbytes - mobileTxBytes;

    // total traffic
    hashMap.put("totRxB", totalRxBytes);
    hashMap.put("totTxB", totalTxbytes);

    // mobile traffic
    hashMap.put("mobRxB", mobileRxBytes);
    hashMap.put("mobTxB", mobileTxBytes);

    return hashMap;
}
 
开发者ID:ddinsight,项目名称:dd-collector,代码行数:22,代码来源:Utils.java

示例8: onCreate

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvSupported = (TextView) findViewById(R.id.tvSupported);
    tvDataUsageWiFi = (TextView) findViewById(R.id.tvDataUsageWiFi);
    tvDataUsageMobile = (TextView) findViewById(R.id.tvDataUsageMobile);
    tvDataUsageTotal = (TextView) findViewById(R.id.tvDataUsageTotal);

    if (TrafficStats.getTotalRxBytes() != TrafficStats.UNSUPPORTED && TrafficStats.getTotalTxBytes() != TrafficStats.UNSUPPORTED) {
        handler.postDelayed(runnable, 0);


        initAdapter();
        lvApplications = (ListView) findViewById(R.id.lvInstallApplication);
        lvApplications.setAdapter(adapterApplications);
    } else {
        tvSupported.setVisibility(View.VISIBLE);
    }
}
 
开发者ID:antonpinchuk,项目名称:trafficstats-example,代码行数:22,代码来源:main.java

示例9: InterfaceTrafficGatherer

import android.net.TrafficStats; //导入方法依赖的package包/类
public InterfaceTrafficGatherer() {
	prevTxBytes = TrafficStats.getTotalTxBytes();
	prevRxBytes = TrafficStats.getTotalRxBytes();
	txBytes = prevTxBytes;
	rxBytes = prevRxBytes;
	nsTimestamp = System.nanoTime();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:8,代码来源:InterfaceTrafficGatherer.java

示例10: run

import android.net.TrafficStats; //导入方法依赖的package包/类
public void run() {
	this.prevRxBytes = this.rxBytes;
	this.prevTxBytes = this.txBytes;
	this.rxBytes = TrafficStats.getTotalRxBytes();
	this.txBytes = TrafficStats.getTotalTxBytes();
	final long timestamp = System.nanoTime();
	this.nsElapsed = timestamp - this.nsTimestamp;
	this.nsTimestamp = timestamp;
	//double perSecMultiplier = 1000d / msInterval;
	this.txTraffic = (nsElapsed > 0 ? (long)((double)(txBytes - prevTxBytes) / (double)(nsElapsed / 1000000000D)) : 0);
	this.rxTraffic = (nsElapsed > 0 ? (long)((double)(rxBytes - prevRxBytes) / (double)(nsElapsed / 1000000000D)) : 0);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:13,代码来源:InterfaceTrafficGatherer.java

示例11: setEndTrafficCounter

import android.net.TrafficStats; //导入方法依赖的package包/类
/**
 * 
 */
private void setEndTrafficCounter() {
	if (USE_PROCESS_UID_FOR_TRAFFIC_MEASUREMENT) {
		this.trafficRxEnd = TrafficStats.getUidRxBytes(processUid);
		this.trafficTxEnd = TrafficStats.getUidTxBytes(processUid);			
	}
	else {
		this.trafficRxEnd = TrafficStats.getTotalRxBytes();
		this.trafficTxEnd = TrafficStats.getTotalTxBytes();			
	}
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:14,代码来源:WebsiteTestServiceImpl.java

示例12: start

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
public int start() {
	if ((trafficRxStart = TrafficStats.getTotalRxBytes()) == TrafficStats.UNSUPPORTED) {
		return SERVICE_NOT_SUPPORTED;
	}		
	running = true;
	trafficTxStart = TrafficStats.getTotalTxBytes();
	return SERVICE_START_OK;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:10,代码来源:TrafficServiceImpl.java

示例13: stop

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
public void stop() {
	if (running) {
		running = false;
		trafficTxEnd = TrafficStats.getTotalTxBytes();
		trafficRxEnd = TrafficStats.getTotalRxBytes();
	}
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:9,代码来源:TrafficServiceImpl.java

示例14: initView

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
protected void initView()
{
	setActionBarTitle(R.string.traffic_statistics);
	
	TrafficStats.getTotalTxBytes();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:8,代码来源:TrafficStatisticsActivity.java

示例15: run

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
        public void run() {
            isNetBad = false;
            long tempSum = TrafficStats.getTotalRxBytes()
                    + TrafficStats.getTotalTxBytes();
            if (isFirst) {
                rxtxTotal = tempSum;
                isFirst = false;
            }
            long rxtxLast = tempSum - rxtxTotal;
            double tempSpeed = rxtxLast * 1000 / 1000;
            rxtxTotal = tempSum;
            if ((tempSpeed / 1024d) < 20 && (rxtxSpeed / 1024d) < 20) {
                time += 1;
            } else {
                time = 0;
            }
            rxtxSpeed = tempSpeed;
            Log.i("NetworkSpeedService", showFloatFormat.format(tempSpeed / 1024d) + "kb/s");
            if (time >= 5) {//连续四次检测网速都小于10kb/s  断定网速很差.
                isNetBad = true;
                Log.i("NetworkSpeedService", "网速差 " + isNetBad);
                time = 0; //重新检测
            }
            if (isNetBad) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        receiverIntent.putExtra("is_slow_net_speed", isNetBad);
                        sendBroadcast(receiverIntent);
//                        NetWorkService.this.stopSelf();
                    }
                });

            }
        }
 
开发者ID:diaoxinqiang,项目名称:NetSpeedService,代码行数:37,代码来源:NetWorkService.java


注:本文中的android.net.TrafficStats.getTotalTxBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。