Android ApiDemos示例解析(15):App->Activity->SetWallpaper
程序员文章站
2022-03-16 20:52:54
...
SetWallpaper介绍如何在Android获取当前Wallpaper,对Wallpaper做些修改,然后用修改后的图像重新设置Wallpaper。
WallpaperManager用来管理Android的Wallpaper。下面代码通过WallpaperManager来取得当前Wallpaper然后显示在屏幕Layout的imageView上。
final WallpaperManager wallpaperManager
= WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable
= wallpaperManager.getDrawable();
final ImageView imageView
= (ImageView) findViewById(R.id.imageview);
imageView.setDrawingCacheEnabled(true);
imageView.setImageDrawable(wallpaperDrawable);
重新设置Wallpaper,也是通过WallpaperManager。
wallpaperManager.setBitmap(imageView.getDrawingCache());
下一篇: RESTful编程究竟是什么?
推荐阅读
-
Android ApiDemos示例解析(19):App->Alarm->Alarm Controller
-
Android ApiDemos示例解析(19):App->Alarm->Alarm Controller
-
Android ApiDemos示例解析(20):App->Alarm->Alarm Service
-
Android ApiDemos示例解析(21):App->Device Admin
-
Android ApiDemos示例解析(21):App->Device Admin
-
Android ApiDemos示例解析(26):App->Notification->IncomingMessage
-
Android ApiDemos示例解析(12):App->Activity->Redirection
-
Android ApiDemos示例解析(15):App->Activity->SetWallpaper
-
Android ApiDemos示例解析(10):App->Activity->QuickContactsDemo
-
Android ApiDemos示例解析(6):App->Activity->Dialog