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.

Android26Live WallpaperWallpaperServicePerformance4Antigravity313

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-07-03
When Universal Links Break Silently — Catching Association Drift with an Agent-Run Verification Gate
Universal Links and App Links fall back to the browser with no error when your association files or entitlements drift apart. Here is a design that generates the files from one source of truth and hands weekly and pre-release checks to an agent.
App Dev2026-07-03
The Failure That Never Shows Up in Your Crash List — Collecting ANR Traces with ApplicationExitInfo and Handing Triage to an Agent
ANRs never reach your crash handler. Here is how I collect them at startup with ApplicationExitInfo and hand triage to an Antigravity agent, with five weeks of real numbers.
App Dev2026-06-26
Hand Over Generation and Shipping, but Never the Signing Key — Designing Key Custody and Handover for an AI-Driven Pipeline
Even in an era where AI Studio and Antigravity take over everything from generation to internal-test shipping, the app signing key is in a class of its own. Lose it, and that app can never be updated again. As a solo developer who has run several apps for years, here is how I design key custody — separating the upload key from the app signing key, storing it, and planning the handover for the worst case.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →