Reputation: 54
I'm working on an android application and I need to set the lock screen wallpaper and normal wallpaper to an animated one. I use a custom Wallpaper Service and set it for the home screen using a new Intent. While this works for the home screen I haven't found a way to make it work on the lock screen, the closest I got is to get it to work on Samsung phones. Now I was wondering if I can do anything to reach my goal.
Here's my current implementation:
Intent intent = new Intent("android.service.wallpaper.CHANGE_LIVE_WALLPAPER");
intent.putExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT", new ComponentName(MainActivity.this, BorderlightWallpaperService.class));
startActivity(intent);
Upvotes: 0
Views: 440
Reputation: 967
As of API Level 24 they have added new methods (and updated the documentation) and flags to the WallpaperManager which allow you to set a Wallpaper not only to the home screen but also to the Lockscreen
To set a Wallpaper to the Lockscreen use the new flag WallpaperManager.FLAG_LOCK, and one of the methods which take int which
WallpaperManager.getInstance(this).setStream(inputStream, null, true,WallpaperManager.FLAG_LOCK);
You can also use one of the following methods
int setStream (InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)
int setResource (int resid, int which)
int setBitmap (Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)
Upvotes: 0