Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can change lockscreen wallpaper in android with code? [duplicate]

Tags:

android

i can change home screen wallpaper but i can not change lock screen wallpaper,

                DisplayMetrics metrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metrics);
                // get the height and width of screen
                int height = metrics.heightPixels;
                int width = metrics.widthPixels;

                WallpaperManager wallpaperManager = WallpaperManager
                        .getInstance(getApplicationContext());

                wallpaperManager.setBitmap(bitmap);


                wallpaperManager.suggestDesiredDimensions(width, height);
like image 899
Mohamed AL-Driny Avatar asked Mar 18 '23 06:03

Mohamed AL-Driny


1 Answers

As of the latest Android API 24 it is possible to update the Lockscreen wallpaper by using the WallpaperManager and providing the FLAG_LOCK flag.

wallpaperManager.setBitmap(bitmap, null, true, WallpaperManager.FLAG_LOCK)
like image 179
mikepenz Avatar answered Apr 06 '23 00:04

mikepenz