The code, called from Application.onCreate()
:
private fun enableOnStrictMode() {
StrictMode.setThreadPolicy(
StrictMode
.ThreadPolicy
.Builder()
.detectAll()
.penaltyLog()
.build())
StrictMode.setVmPolicy(
StrictMode
.VmPolicy
.Builder()
.detectAll()
.penaltyLog()
.build())
}
This works perfectly fine on an Android 9.0 Pie device and outputs almost a dozen policy violations including un-tagged network requests and disk reads. But when running the same code on a Marshmallow device (a Samsung J5 Android 6.0) StrictMode outputs no logging, even when it seems reasonable to assume the policy violations are still occurring.
Is there something about the StrictMode configuration that might lead to no output on Android 6.0 Marshmallow?
Certain detections are only available starting with later API versions.
For example, API level 26 (Android O) added detectUntaggedSockets
and detectUnbufferedIo
.
However, detectDiskReads
should be available starting with API level 9.