Android设置桌面背景图片的实现方法

 更新时间:2013年06月06日 00:47:32   作者:  
有时候我们需要用android设置桌面背景图片,这里简单分享下,方便需要的朋友
1.设置桌面背景图片的方法

复制代码 代码如下:

Resources res=getResources();
BitmapDrawable bmpDraw=(BitmapDrawable)res.getDrawable(R.drawable.icon);
Bitmap bmp=bmpDraw.getBitmap();
try{
setWallpaper(bmp);
}catch(IOException e) {
e.printStackTrace();
}


2.在manifest中增加设置桌面的权限

<uses-permission android:name="android.permission.SET_WALLPAPER" />

相关文章

最新评论