Alternative to "FLAG_BLUR_BEHIND" in Android?
Asked Answered
E

3

20

I can see that when I use the same flag as shown on the API-demos for blurring the background, I get a warning that it's deprecated:

"The field WindowManager.LayoutParams.FLAG_BLUR_BEHIND is deprecated".

I've read about it, and I've found that "Blurring is no longer supported".

Does it mean that it won't work on future versions? Why did they deprecate it? Is there an alternative? I really like this feature.

Echinoderm answered 29/4, 2012 at 13:15 Comment(3)
groups.google.com/forum/?fromgroups#!topic/android-developers/… says it does not work anymore and you can't replace itPolynesian
is there an alternative which would use the GPU/CPU for this?Echinoderm
You can probably write your own if you take a screenshot of the current screen, blur that and use it as background to your dialog or something like that but there is afaik nothing built-inPolynesian
E
11

ok , there is probably no alternative that uses the API , unless maybe i've forgetting anything.

i can however use dimming , which is cool too, as written here:

WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();  
lp.dimAmount=0.0f;  
dialog.getWindow().setAttributes(lp);  
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);  
Echinoderm answered 30/4, 2012 at 9:9 Comment(6)
another alternative is shown here : youtube.com/… meaning getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) or use getWindow().setBackground(new ColorDrawable(0x7f000000)Echinoderm
setBackgroundDrawable() not setBackground() at least for meUnsure
indeed, the line of code in the Google video is wrong. It should say getWindow().setBackgroundDrawable(new ColorDrawable(0x7000000));Lifeanddeath
You can save yourself a few lines with just dialog.getWindow().setDimAmount(0.0f);Mylohyoid
FLAG_BLUR_BEHIND flag is deprecated in api level 14Thereby
@Thereby Does it mean it doesn't work? I think it still works.Echinoderm
N
2

watch out that

WindowManager.LayoutParams.FLAG_BLUR_BEHIND

is deprecated.. (at least at Android 4.0 it leads to a black screen in background...)

Reference (Source): http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html

int FLAG_BLUR_BEHIND This constant is deprecated. Blurring is no longer supported.

public static final int FLAG_BLUR_BEHIND

Since: API Level 1
This constant is deprecated.
Blurring is no longer supported.

Window flag: blur everything behind this window.

Constant Value: 4 (0x00000004)

what a pitty .. :( (was a nice effect ;))

Nominee answered 28/6, 2012 at 14:59 Comment(8)
how come ? it's a cool effect. also , how do you know (in the API website) from which version this constant is deprecated? in addition , what would happen if i use it on android 4?Echinoderm
if u use it on android 4.0 the background is not blurred, it's straight black, no effect at all, also doesnt look very well, because on all other devices it's nicely blurred ... to your other question, i edited my answer above: look there: )Nominee
the link you gave is the API website , which is the one i've read about . they don't say from which version of android this feature is not available ...Echinoderm
sry no idea exactly, but first time i realized it was with android 4.0Nominee
you know , it's weird that the API website doesn't tell anything about deprecated things . they should add a description of why it's deprecated , alternatives , and from which version it's deprecated.Echinoderm
hehe ;) yeah definitly, would be much more better :) interesting :) easier :) - each and every thing u mentioned :)Nominee
Funnier is the fact that iOS 7 currently integrates it as a native functionality.Lactary
:( ;=) .... there are several algorithms to create a blurred screenshot and just show it (but much effort and high performance needed :()Nominee
R
0

I Think u should try ShowCaseView Library. For Highlighting the Elements on Android.

The ShowcaseView library is designed to highlight and showcase specific parts of apps to the user with a distinctive and attractive overlay. This library is great for pointing out points of interest for users, gestures, or obscure but useful items.

Github Link : https://github.com/amlcurran/ShowcaseView

Receptive answered 25/8, 2014 at 6:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.