images.The WallpaperManager class is used for all wallpaper interaction.
The current wallpaper can be retrieved with a call to the getDrawable() or
peekDrawable() methods.The methods getDesiredMinimumHeight() and
getDesiredMinimumWidth() enable the application to programmatically determine the
size that a wallpaper should be on the particular handset. Finally, you can assign wallpaper
through the setResource(), setBitmap(), and setStream() methods.
The following callback of the Camera object sets the wallpaper:
public void onPictureTaken(byte[] data, Camera camera) {
Bitmap recordedImage =
BitmapFactory.decodeByteArray(data, 0, data.length);
try {
WallpaperManager wpManager = WallpaperManager
.getInstance(StillImageActivity.this);
wpManager.setBitmap(recordedImage);
} catch (Exception e) {
Log.e("Still", "Setting wallpaper failed.", e);
}
}
The image is copied locally for the wallpaper, so the original doesn't need to be kept,
which is good in this case because it was never written to disk.You can remove the wallpaper
completely with a call to the clear() method.
Finally, your application needs the android.permission.SET_WALLPAPER permission
within the AndroidManifest.xml file.
0 件のコメント:
コメントを投稿