[SetWallpaperActivity.java]
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);
Button randomize = (Button) findViewById(R.id.randomize);
randomize.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
int mColor = (int) Math.floor(Math.random() * mColors.length);
wallpaperDrawable.setColorFilter(mColors[mColor],
PorterDuff.Mode.MULTIPLY);
imageView.setImageDrawable(wallpaperDrawable);
imageView.invalidate();
}
});
Button setWallpaper = (Button) findViewById(R.id.setwallpaper);
setWallpaper.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
try {
wallpaperManager.setBitmap(imageView.getDrawingCache());
finish();
} catch (IOException e) {
e.printStackTrace();
}
* Drawable class로 그림을 그리고 WallpaperManager로 바탕화면을 지정한다.
'old > API_Demo' 카테고리의 다른 글
APP_Activity_TranslucentBlurActivity (0) | 2010.03.16 |
---|---|
APP_Activity_TranslucentActivity (0) | 2010.03.16 |
APP_Activity_ReorderActivities (0) | 2010.03.16 |
APP_Activity_Redirection (0) | 2010.03.16 |
APP_Activity_ReceiveResult (0) | 2010.03.16 |