I would to check if my Live Wallpaper App is set as Live Wallpaper.
The following code works on Android <= 12, but not in Android 13 (sdk 33).
public static boolean isLiveWallpaper(Context context) {
if (Service._handler == null) {
return false;
}
WallpaperManager wpm = WallpaperManager.getInstance(context);
WallpaperInfo info = wpm.getWallpaperInfo();
try {
return (info != null && info.getPackageName().equals(context.getPackageName()));
} catch (Exception e) {
return false;
}
}
On Android 13 wpm.getWallpaperInfo()
always return null
.
Why? I searched on Google and on the Android Developer Documentation, but I did'n find anything...
Edit: I set the live wallpaper with this code and it works, but I can't check programmatically if the live wallpaper is setted.
Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
new ComponentName(context, Service.class));
context.startActivity(intent);