Android学习笔记(四) android 更换桌面壁纸-----WallpaperManager

来源:互联网 发布:有限元网格划分软件 编辑:程序博客网 时间:2024/05/17 09:30

Android 中壁纸管理主要由 WallpaperManager 这个类负责

 

 

Provides access to the system wallpaper. With WallpaperManager, you can get the current wallpaper, get the desired dimensions for the wallpaper, set the wallpaper, and more. Get an instance of WallpaperManager with getInstance().

 

 

他的初始化方法为

wallpaperManager = WallpaperManager.getInstance(this); 

 

获取当前壁纸的方法为:

Drawable drawable = wallpaperManager.getDrawable();

 

设置一张图片作为壁纸的方法为

 

 

 

 

下面是实现效果:

 

 

更换壁纸后:

 

 

具体代码为:

 

 

原创粉丝点击