我可以更改主屏幕壁纸,但我无法更改锁屏壁纸,
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);
答案 0 :(得分:5)
从最新的Android API 24开始,可以使用Lockscreen
更新WallpaperManager
壁纸并提供FLAG_LOCK
标记。
wallpaperManager.setBitmap(bitmap, null, true, WallpaperManager.FLAG_LOCK)