0

Let's say an Android application acquires a wake-lock, and then launches another application by sending it an explicit intent. Does the effect of acquisition of wake-lock last while the other application is in the foreground ?

bdutta74
  • 2,798
  • 3
  • 31
  • 54

1 Answers1

1

As described in Keeping the Device Awake it's perfectly natural for a background application to grab and hold a CPU wakelock:

One legitimate case for using a wake lock might be a background service that needs to grab a wake lock to keep the CPU running to do work while the screen is off. Again, though, this practice should be minimized because of its impact on battery life.

This action is pretty common. For example, imagine a music playing application. Even though the screen is off, or some other activity is in the foreground, it's fine for a background application to hold a wake lock to keep playing music.

Although that last line should really take a warning. As described in Wakelocks and Battery Drain those things tend to burn through battery pretty fast; and worse yet, is that it's a pretty common problem to not release them properly, and end up putting the device into a sleepless mode, where it never goes to sleep.

Colt McAnlis
  • 3,846
  • 3
  • 18
  • 19
  • Thanks for the answer. If an application that acquired a wake-lock were to cause another application to be started, by sending it an explicit intent, does the effect of holding the wake-lock extend to the new application as well ? I guess so. – bdutta74 Aug 20 '15 at 11:43
  • Wakelocks are absolute. App A holds a wakelock; even though app B may be in the foreground, A can still keep the CPU awake. – Colt McAnlis Aug 20 '15 at 12:28
  • Ah, thanks. That answers my question completely and thus accepting the answer. – bdutta74 Aug 20 '15 at 13:01