I want to set image as wallpaper in my android app, there is my code:
private class SetAsBackground implements View.OnClickListener {
@Override
public void onClick(View v) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
Looper.prepare();
try {
mShareBitmap = Glide.with(WallPaperDetails.this).load(mImageURL).asBitmap()
.into(-1, -1).get();
} catch (final ExecutionException | InterruptedException e) {
Log.e("loading_fail", e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void dummy) {
if (null != mShareBitmap) {
new ImageSaver(WallPaperDetails.this)
.setFileName("wallpaper.png")
.setDirectoryName("fine")
.save(mShareBitmap);
WallpaperManager myWallpaperManager = WallpaperManager
.getInstance(WallPaperDetails.this);
try {
Bitmap bitmap = new ImageSaver(WallPaperDetails.this)
.setFileName("wallpaper.png")
.setDirectoryName("fine").load();
myWallpaperManager.setBitmap(bitmap);
Toast.makeText(WallPaperDetails.this,
"Wallpaper successfully changed", Toast.LENGTH_SHORT)
.show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.execute();
}
}
but I want to make like this:
How can I do that ? Now I am using wallpaper manager with image saver class(I can share the code of image saver class). While searching in google, I didn't find any other answer. If you can explain how that app do that, or share some code...