Return amount in bytes of the mobile data used per day

2

Hello, I have a problem in returning the amount in bytes of data consumed via mobile data in android.

I'm currently using this code:

Calendar beginCal = Calendar.getInstance();
        beginCal.set(Calendar.DATE, 1);
        beginCal.set(Calendar.MONTH, 0);
        beginCal.set(Calendar.YEAR, 2015);

        Calendar endCal = Calendar.getInstance();
        endCal.set(Calendar.DATE, 1);
        endCal.set(Calendar.MONTH, 0);
        endCal.set(Calendar.YEAR, 2016);

        UsageStatsManager lUsageStatsManager = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
        final List<UsageStats> queryUsageStats= lUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_YEARLY, beginCal.getTimeInMillis(), endCal.getTimeInMillis());

But my queryUsageStats is returning 0. In this case I am trying to catch the 1 year period.

Would anyone know of another way to return this data?

Thank you in advance.

    
asked by anonymous 02.02.2016 / 19:27

0 answers