gpt4 book ai didi

android - 获取 Android 数据使用历史的最详细信息

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:24:09 25 4
gpt4 key购买 nike

我需要获取 Android 设备的数据使用历史记录。

我可以拥有这些功能中的哪些?以及如何?

1-Daily data usage or even hourly.

2-From the last device data wipe date to now.

3-Contains application details.

注意

I don't want to monitor and save data usage history.

I want to have it all after installing the application.

**Please** tell if there is more than one way And also if thy need Root access
Or if they work on a specific API version.

最佳答案

回到过去,我想在不监视设备的情况下捕获设备的数据使用情况。当时我知道的唯一方法是在后台使用服务捕获所有内容,我认为这会占用大量 CPU。 (TrafficStats 是当时返回的唯一途径)

为了回答可能会看到它的其他人的问题,我应该说以下内容。

  • API 23 中有一个名为 NetworkStatsManager 的函数那可以做到这一点。我还应该链接到 this answerhis work ongithub .
  • 根据谷歌文档,您可以获得 Long.MIN_VALUE 和 Long.MAX_VALUE 之间任何时间段的数据使用情况。

    Queries can define a time interval in the form of start and end timestamps (Long.MIN_VALUE and Long.MAX_VALUE can be used to simulate open ended intervals).

  • 您可以根据它们的 UID 分类获取其他应用程序的使用情况,然后您可以转向包名称等。( Referral project )

  • documentation 中有 5 种方法可以做到这一点.

    Summary queries

    querySummaryForDevice(int, String, long, long)

    querySummaryForUser(int, String, long, long)

    querySummary(int, String, long, long)

    These queries aggregate network usage across the whole interval. Therefore there will be only one bucket for a particular key, state, metered and roaming combination. In case of the user-wide and device-wide summaries a single bucket containing the totalised network usage is returned.

    History queries

    queryDetailsForUid(int, String, long, long, int)

    queryDetails(int, String, long, long)

    These queries do not aggregate over time but do aggregate over state, metered and roaming. Therefore there can be multiple buckets for a particular key. However, all Buckets will have state NetworkStats.Bucket.STATE_ALL, defaultNetwork NetworkStats.Bucket.DEFAULT_NETWORK_ALL, metered NetworkStats.Bucket.METERED_ALL, roaming NetworkStats.Bucket.ROAMING_ALL.

关于android - 获取 Android 数据使用历史的最详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38090264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com