WallpaperService壁纸实现

1.使用Bitmap作为壁纸

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);    
try {       
 Bitmap wallpaperBitmap = BitmapFactory.decodeResource(getResources(), R.raw.girl);        
 wallpaperManager.setBitmap(wallpaperBitmap);    
} catch (IOException e) {        
e.printStackTrace();    
}

使用静态资源设置壁纸

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);    
try {        
wallpaperManager.setResource(R.raw.wallpaper);    
} catch (IOException e) {        
e.printStackTrace();   
 }

清除壁纸

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);    

你可能感兴趣的:(WallpaperService壁纸实现)