如何衡量我的应用程序的数据使用情况(How to measure data usage of my app)

编程入门 行业动态 更新时间:2024-10-25 08:24:20
如何衡量我的应用程序的数据使用情况(How to measure data usage of my app)

我正在开发一个需要下载大量数据的Android应用程序。

为了提高可用性,我想测量应用程序产生的数据流量,并在应用程序下载特定数量的数据时为用户提供提示。

我目前的想法:将所有下载的字节总和在一起并对指定的限制作出反应。 但是,由于我在许多不同的情况下以及代码中的许多不同位置下载了东西,还有其他可能性来衡量每个应用程序的数据使用情况吗?

AFAIK, sys/net/NETINTERFACE/statistics/rx_bytes报告整个系统的总量,所以这不是一个解决方案。

I'm developing an Android app which needs to download a lot of data.

To improve the usability, I'd like to measure the data traffic my app produces and give the users a hint if the app downloaded a specific amount of data.

My current idea: Sum all downloaded bytes together and react on a specified limit. However, as I downloaded things in many different situations and in many different positions in the code, is there any other possibility to measure the data usage per app?

AFAIK, sys/net/NETINTERFACE/statistics/rx_bytes reports the total amount of the whole system, so this is not a solution.

最满意答案

但是,由于我在代码中的许多不同位置和许多不同位置下载了内容,是否有其他可能性来衡量每个应用程序的数据使用情况?

TrafficStats可以通过UID报告事情。 我说“可能”是因为它似乎与设备有关。 我怀疑Android 3.0+会一直由UID报告,但我的2.2和2.3经验混杂在一起。

这里是一个示例应用程序演示记录这些信息。

However, as I downloaded things in many different situations and in many different positions in the code, is there any other possiblity to measure the data usage per app?

TrafficStats may be able to report things by UID. I say "may" because it seems tied to devices. I suspect that Android 3.0+ will consistently report by UID, but my 2.2 and 2.3 experience has been mixed.

Here is a sample application demonstrating recording this information.

更多推荐

本文发布于:2023-08-05 17:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1435716.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   情况   数据   measure   usage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!