harsh_v
harsh_v

Reputation: 3269

Dealy in wallpaperManager.setBitmap (bitmap)

I am trying to change wallpaper using a widget. I use the code below to achieve that: But there is an certain delay every time the code is executed.

Is there any way to avoid this delay.

...
WallpaperManager wallpaperManager = WallpaperManager.getInstance (context);
Bitmap bitmap = BitmapFactory.decodeStream (new FileInputStream (file));

//here @file is fetched from a phone storage

wallpaperManager.setBitmap (bitmap);
...

Upvotes: 1

Views: 826

Answers (1)

F43nd1r
F43nd1r

Reputation: 7749

I see four options which might help here:

  1. Reduce the size of the bitmap before saving it to the file
  2. Preload the bitmap (well, if possible)
  3. Do all this asyncronous
  4. Make sure your heap is as empty as possible before loading the bitmap. If android has to free heap while decoding a large bitmap it will slow down noticeably

Upvotes: 1

Related Questions