Skip to content

fix: handle missing live wallpaper chooser activity - #38

Merged
Attacktive merged 2 commits into
mainfrom
bugfix/handle-missing-wallpaper-activity
Aug 27, 2026
Merged

fix: handle missing live wallpaper chooser activity#38
Attacktive merged 2 commits into
mainfrom
bugfix/handle-missing-wallpaper-activity

Conversation

@Attacktive

Copy link
Copy Markdown
Owner

Problem

On certain devices (such as Android Go edition devices or stripped OEM ROMs without a live wallpaper preview component), calling startActivity with WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER throws android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.service.wallpaper.CHANGE_LIVE_WALLPAPER (has extras) }.

Solution

When setting the live wallpaper from the home screen:

  1. Attempt WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER with the target component.
  2. Fall back to WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER if the direct change intent is unavailable.
  3. Fall back to Intent.ACTION_SET_WALLPAPER if the live wallpaper chooser is unavailable.
  4. Catch ActivityNotFoundException and SecurityException and display a toast notification if no wallpaper chooser
    activity is available on the device.

When setting the live wallpaper from the home screen:
1. Attempt WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER with the target component.
2. Fall back to WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER if the direct change intent is unavailable.
3. Fall back to Intent.ACTION_SET_WALLPAPER if the live wallpaper chooser is unavailable.
4. Catch ActivityNotFoundException and SecurityException and display a toast notification if no wallpaper chooser activity is available on the device.

Co-authored-by: Gemini 3.7 Flash <noreply@google.com>
@Attacktive Attacktive self-assigned this Aug 27, 2026
@Attacktive Attacktive added the bug Something isn't working label Aug 27, 2026
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Attacktive

This comment was marked as resolved.

Co-authored-by: Gemini 3.7 Flash <noreply@google.com>
@Attacktive

Copy link
Copy Markdown
Owner Author

Code review

Resolved by cc36d67. With Intent(Intent.ACTION_SET_WALLPAPER) gone, a device that resolves neither live-wallpaper action now falls through both startActivity calls, exhausts the loop, and reaches the toast — so the failure is surfaced instead of silently redirecting to the static picker.

private fun setLiveWallpaper(context: Context) {
val intents = listOf(
Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
.putExtra(
WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
ComponentName(context, WeatherLiveWallpaperService::class.java)
),
Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER)
)
for (intent in intents) {
try {
context.startActivity(intent)
return
} catch (_: ActivityNotFoundException) {
// Fall through to the next intent.
} catch (_: SecurityException) {
// Fall through to the next intent.
}
}
Toast.makeText(context, "Unable to open wallpaper chooser", Toast.LENGTH_SHORT)
.show()
}

No further issues.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@Attacktive
Attacktive merged commit cc36d67 into main Aug 27, 2026
6 checks passed
@Attacktive
Attacktive deleted the bugfix/handle-missing-wallpaper-activity branch August 27, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant