1、获取桌面壁纸:
调用:layout.setBackground(getWallpaperDrawable()); private Drawable getWallpaperDrawable() {Drawable wallpaperDrawable;PackageManager pm = getApplicationContext().getPackageManager();WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);if (wallpaperManager.getWallpaperInfo() != null) {/** Wallpaper info is not equal to null, that is if the live wallpaper* is set, then get the drawable image from the package for the* live wallpaper*/wallpaperDrawable = wallpaperManager.getWallpaperInfo().loadThumbnail(pm);} else {/** Else, if static wallpapers are set, then directly get the* wallpaper image*/wallpaperDrawable = wallpaperManager.getDrawable();}return wallpaperDrawable;}
2、设置锁屏:
在manifest中,一定要做配置:
<activity android:name=".LockScreenActivity"android:taskAffinity=".lockscreen"android:theme="@android:style/Theme.Translucent"/>