I'm pretty new to Android programming so bear with me.
I was wondering if there was a method of retrieving the current wallpaper on an android device and saving it to a variable in your app's code.
Thanks
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
This is the good way to do that:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
This goes a step further and saves the file. You'll need exception handling of course and you'll need external write permission.
import java.io.FileOutputStream;
import android.graphics.Bitmap;
import android.app.WallpaperManager;
WallpaperManager wmInstance = WallpaperManager.getInstance(context);
wmInstance
.getDrawable()
.getBitmap()
.compress(Bitmap.CompressFormat.PNG, 100,
new FileOutputStream("/storage/emulated/0/output.png"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With