yxwkf
		// ---------------------流量统计--------------------------------
		try {
			PackageManager pm = getPackageManager();
			ApplicationInfo ai = pm.getApplicationInfo("com.test.app",
					PackageManager.GET_ACTIVITIES);// com.test.app为自己应用的包名
			Log.d("!!", "!!" + ai.uid);
			long received = TrafficStats.getUidRxBytes(ai.uid);// 获取某个网络UID的接受字节数
			long sent = TrafficStats.getUidTxBytes(ai.uid);// 获取某个网络UID的发送字节数
			Toast.makeText(mContext, "累计接收数据" + received / 1024 + "KB",
					Toast.LENGTH_SHORT).show();
			Toast.makeText(mContext, "累计发送字节" + sent / 1024 + "KB",
					Toast.LENGTH_SHORT).show();
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		// -----------------------------------------------------

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2021-11-19
  • 2022-01-03
  • 2021-06-09
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2022-01-23
  • 2021-12-10
  • 2021-12-10
  • 2021-07-26
  • 2021-12-10
相关资源
相似解决方案