NetworkStatsManager: get an error when I query

1.1k views Asked by At

When I implement a network stat history, I get this error:

Caused by: java.lang.SecurityException: Network stats history of uid -1 is forbidden for caller 10160

Here is the code:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        networkStatsManager = getApplicationContext().getSystemService(NetworkStatsManager.class);

        try {
            Log.v("Tethering activity: ", networkStatsManager.queryDetailsForUid(ConnectivityManager.TYPE_MOBILE,
                    "", 0, System.currentTimeMillis(), NetworkStats.Bucket.UID_ALL));
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

Do you have an explanation?

0

There are 0 answers