◉ANTIGRAVITY LABJP
Articles/App Development
▣ App Development/2026-07-06Advanced

Building a Live Wallpaper That Doesn't Drain the Battery — Designing the WallpaperService Render Loop Around a Power Budget

Live wallpapers quietly burn battery because they keep drawing when nothing is visible. Here is the WallpaperService.Engine design I used to cut power draw by roughly 60% in a real wallpaper app, built around visibility, idle, and thermal gates.

Android28Live WallpaperWallpaperServicePerformance6Antigravity421

✦ Premium Article

One day a wallpaper app of mine — slowly twinkling stars — picked up this review: "The art is nice, but the day I set it, my battery started draining about twice as fast." Only a few hundred stars, nothing but a simple alpha fade. Yet on a real device the CPU kept working even with the screen off, and the phone stayed faintly warm.

Live wallpaper rendering has a habit of running even when nobody is looking. Every time you return to the home screen, switch apps, or lock the phone, the render thread keeps going unless you have designed it not to. As an indie developer, I rebuilt the render loop of my wallpaper app and cut battery use by around 60%. This is that design, and I leaned on an Antigravity agent to grind through the measurements.

Why live wallpapers really burn power

Most sample code drives draw() on a fixed interval with Handler.postDelayed. It looks fine while running, but from a power standpoint it has three holes.

The first is drawing without regard to visibility. If your loop keeps going after onVisibilityChanged(false), it renders even while another app fully covers the home screen. The second is redrawing frames whose content has not changed. When the stars come to a complete rest, or an animation loops back to an identical image, faithfully redrawing at 60fps still keeps the GPU and the display compositor busy. The third is ignoring thermal state: if the device throttles under heat but you keep requesting a high frame rate, the system drops clocks and the cost per frame actually rises — a vicious loop.

In other words, live wallpaper power is decided less by how complex the art is and more by when you decide to stop drawing. I started from that premise and rebuilt the engine so that the conditions for stopping are explicit.

Working backward from a power budget

Set the budget first. My rule of thumb: 60fps while the screen shows the wallpaper, zero drawing while static or idle, and an average added draw of no more than 30mAh per hour of screen-on time. On a 3,000–4,000mAh device that is roughly 1% per hour. Fix the ordering up front: if you cross that ceiling, you drop the frame rate even at the cost of the art.

To hold the budget, insert three gates into the render loop. A visibility gate (do not draw if not visible), an idle gate (do not draw if nothing changed), and a thermal gate (lower the frame rate when hot). All three only ever push in the direction of drawing less. By never adding a path that increases work, you prevent runaway draw structurally.

GateSignalEffect
VisibilityonVisibilityChangedFully stop the render thread while hidden
IdleFrame diff / input presenceDo not request the next frame if unchanged
ThermalPowerManager thermal callbacksStep down 60→30→10fps under heat
✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦A WallpaperService.Engine that stops drawing based on three axes: visibility, idle, and thermal state
✦Adaptive frame pacing that steps down 60→30→10fps, measured to cut power draw by up to 62%
✦A measurement pipeline that hands adb and dumpsys batterystats to an Antigravity agent
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

▣ App Dev2026-10-22
Translations Drifted Apart Without Me Noticing: A 70-Line strings.xml Check to Run Before Asking an Agent to Review
A small Python script that finds missing keys, empty strings, placeholder mismatches, and missing plurals across Android locales, how it divides the work with Lint, and how to hand only its findings to Antigravity for fix proposals.
▣ App Dev2026-05-25
One Month Splitting Antigravity's Inline Edit and Agent Mode Across Four Wallpaper Apps
A month of notes from running Antigravity's Inline Edit and Agent Mode across four production wallpaper apps — with real counts, the decision rule I wrote into AGENTS.md, a one-pass dSYM fix, and how credit cost factors in.
▣ App Dev2026-11-23
From December 1, Someone Else Answers gemini-2.5-flash: Find Every Place You Hard-Coded the Name First
On December 1 the Gemini API starts routing gemini-2.5-pro to gemini-3.8-flash and gemini-2.5-flash to gemini-3.5-flash-lite, billed at the new models' rates. Nothing errors, so it is easy to miss. Here is a script that finds model names across code, config and MCP settings, plus a way to log modelVersion so you can see the switch yourself.