2

About the app - I am a making my app background a blurred wallpaper. It is easy to get wallpaper as drawable using getWallpaper() method in an Activity. I then convert drawable to bitmap and use a blur algorithm to blur the bitmap and then set it as a background image. This whole process takes some time around 1 to 5 seconds. So I decided to put the blurred wallpaper in SD card so I need to just get that image from sd card then it will not take so much time. So every time user change the wallpaper I need to make that wallpaper blurred and save it to SD card. For that I need ACTION_WALLPAPER_CHANGED broadcast receiver.

Problem - ACTION_WALLPAPER_CHANGED intent filter works fine before API 16 but from API 16 it is deprecated and does not broadcast wallpaper changed action.

I want that whenever user change the background I need my app background changed to that blurred image of the wallpaper.

Sunny
  • 14,522
  • 15
  • 84
  • 129
  • 1
    How about following a different approach (not sure if this will work): As advised in the docs, use the flag `WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER` to show the wallpaper behind your activity's UI. Start the blurring process on bitmap generated using `getWallpaper()`. Since bitmap-blurring is a multi-stage process, you can use the 5 second delay to your advantage.... (contd). – Vikram Nov 15 '13 at 22:41
  • 1
    (...) Say, you go through 10 stages to create the blurred bitmap. On every stage (every ~ 0.5 seconds), use the resulting bitmap to set the background: `getWindow().setBackgroundDrawable(new BitmapDrawable(getResources(), processedBitmap))`. It _should_ give you a (smooth?) blurring effect. Needless to say that bringing down the 5 seconds to something less-noticeable would help. – Vikram Nov 15 '13 at 22:42
  • 1
    Another way: When your app starts (for the first time), retrieve the bitmap using `getWallpaper()`, blur it, and save the _original_ and _blurred copy_ to SD card. On subsequent launches, retrieve the bitmap using `getWallpaper()` and compare it with the _original_ you saved on last launch using: `bitmapFromGetWallpaper.sameAs(originalFromSDCard)`. If they are the same, use the blurred copy from SD card. Else, blur `bitmapFromGetWallpaper` and update original and blurred copy on SD card. The delay should now only be when the user changes the wallpaper: same as before the deprecation. – Vikram Nov 15 '13 at 23:04
  • 1
    Hi Thanks! @user2558882 I took your second approach. and also If API <16 I also used broadcast receiver. – Sunny Nov 16 '13 at 10:45

1 Answers1

0

Since you wont get the broadcast anymore, wouldn't be the best direction for you to try and improve performance on your blurring method, and do it on-the-fly without SD card storage?

The thing is, for the user to change the background, they pretty much have to leave your app (and that you can still notice), and getting down to at most say a second for the blurring when they re-enter your app should still be ok-ish user experience.

Maybe have a look here (if you haven't already), regarding fast image blur on android:

Fast Bitmap Blur For Android SDK

Community
  • 1
  • 1
bgse
  • 8,237
  • 2
  • 37
  • 39
  • Thanks for your advice! I am already using fast blur. It also takes some times around 1-5 seconds depending on the image. I used second approach in comments above. – Sunny Nov 16 '13 at 10:47