当前位置: 代码迷 >> Android >> Android中进展流量统计
  详细解决方案

Android中进展流量统计

热度:53   发布时间:2016-04-28 04:29:27.0
Android中进行流量统计
		// ---------------------流量统计--------------------------------		try {			PackageManager pm = getPackageManager();			ApplicationInfo ai = pm.getApplicationInfo("com.orimuse.app",					PackageManager.GET_ACTIVITIES);// com.orimuse.app为自己应用的包名			Log.d("!!", "!!" + ai.uid);			long received = TrafficStats.getUidRxBytes(ai.uid);// 获取某个网络UID的接受字节数			long sent = TrafficStats.getUidTxBytes(ai.uid);// 获取某个网络UID的发送字节数			Toast.makeText(mContext, "orimuse累计接收数据" + received / 1024 + "KB",					Toast.LENGTH_SHORT).show();			Toast.makeText(mContext, "orimuse累计发送字节" + sent / 1024 + "KB",					Toast.LENGTH_SHORT).show();		} catch (NameNotFoundException e) {			e.printStackTrace();		}		// -----------------------------------------------------
  相关解决方案