Reputation: 31
I'm trying to change the wallpaper with an alarm, it sometimes works and sometimes doesn't, it doesn't show any error or other kind of logs in the console, checked for nulls and nothing.
Tried first without picasso and once I got the error I though it maybe an issue where the bitmap doesnt load before the wallpapermanager changes it, so I tried Picasso and the result is the same, sometimes works sometimes doesn't
Picasso.with(context).load(Uri.parse(uriString)).into(new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
try {
wallpaperManager.setBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
UPDATE:
Sometimes it also changes the wallpaper with an uncompleted image with a black margin on the right.
Any help would by appreciated. Thanks
Upvotes: 3
Views: 100