can help me?
Il giorno giovedì 19 maggio 2016 12:50:52 UTC+2, Mauro Esposito ha scritto:
>
> I'm making an App for Android 6.0 and I want to use the new class
> NetworkStatsManager for getting mobile data usage.
>
> I added all permission I need in manifest and require the permission
> runtime.
>
> When I call the method:
>
> bucket =
> networkStatsManager.querySummaryForDevice(ConnectivityManager.TYPE_WIFI, "",
> fromDate.getTime(), toDate.getTime());
>
> return the right value for WIFI usage.
>
> But if i replace TYPE_WIFI with TYPE_MOBILE the result is always 0.
>
> NetworkStats.Bucket bucket = null;
> try {
> bucket =
> networkStatsManager.querySummaryForDevice(ConnectivityManager.TYPE_MOBILE,
> "", fromDate.getTime(), toDate.getTime());
>
> if(bucket == null){
> Log.i("Info", "Error");
> }else{
> Log.i("Info", "Total: " + (bucket.getRxBytes() +
> bucket.getTxBytes()));
> }
>
> } catch (RemoteException e) {
> e.printStackTrace();
> }
>
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/838ea9db-0dd6-4211-8c80-d46d6d4c8b4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.