Inspectopedia Help

Using wakeLock without timeout

Using wakeLock without timeout

Wakelocks have two acquire methods: one with a timeout, and one without. You should generally always use the one with a timeout. A typical timeout is 10 minutes. If the task takes longer than it is critical that it happens (i.e. can't use JobScheduler) then maybe they should consider a foreground service instead (which is a stronger run guarantee and lets the user know something long/important is happening).

Issue id: WakelockTimeout

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3


Android, 2022.3.1 Beta 2

Last modified: 13 July 2023