The project I am working on is a Profile Owner Application. I want to get the Network logs. I have successfully enabled the NetworkLogging and checked the Network logging enable status by setNetworkLoggingEnabled() and isNetworkLoggingEnabled() methods.
Now I want to get the network logs using the retrieveNetworkLogs() method. which requires the parameter "batchToken : Long".
I have tried several ways to get the batchToken but have failed to get it. Now, I want your kind opinion on how to get the batchToken value and solve this problem by calling the retrieveNetworkLogs() method.
Thank you for your time.
val devicePolicyManager = getSystemService(Activity.DEVICE_POLICY_SERVICE) as DevicePolicyManager?
//ComponentName is null because it is called by a delegated app.
devicePolicyManager?.setNetworkLoggingEnabled(null,true) val isEnable = devicePolicyManager?.isNetworkLoggingEnabled(null) val initialLogs = devicePolicyManager?.retrieveNetworkLogs(null, batchToken)
//need to know where to get this batchToken value
You need to extend the DelegateAdminReceiver class. Their you can get the batch token.
Android API: https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#onNetworkLogsAvailable(android.content.Context,%20android.content.Intent,%20long,%20int)