我有壁纸的应用程序,我允许用户直接从应用程序设置壁纸.在这里,我将图像的http url转换为Bitmap并调用
Android的WallpaperManager类.
以下是将URL转换为位图并设置为WallpaperManager位图的代码:
private void setWallpaper() {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
try {
Bitmap image = getBitMapFromHttpURL();
if (image != null) {
wallpaperManager.setBitmap(getBitMapFromHttpURL());
image.recycle();
image = null;
} else {
Toast.makeText(this, "Failed to set wallpaper",
Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
} catch (Exception es) {
}
}
它在此行上失败了wallpaperManager.setBitmap(getBitMapFromHttpURL());除以下异常:
java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://