Skip to content
Advertisement

Code for setting light status bar in android 11 and below android 11 deprecation warning not going

JavaScript

I am using this code for setting light status bar in android 11 and below android 11. Everything works fine, just a little problem, deprecation warning not going.

Advertisement

Answer

I just did one thing, since my if statement is fine, I just suppressed warning by using @SuppressWarnings(“deprecation”)

I just used this annotation for that particular method which contains this code.

There is another option present which is also perfectly fine: just add

JavaScript

above line of code which is deprecated. This will allow to check other warnings in that whole function. Which is good and I will prefer.

What is the advantage of //noinspection deprecation over @SuppressWarnings(“deprecation”)?

This prevents the problem with @SupressWarnings, which is it ignores all warnings in the method. So if you have something deprecated that you are not aware of, @SupressWarnings will hide it and you will not be warned. That is the advantage of the //noinspection

Courtest and check more details in this post answers: How to suppress specific Lint warning for deprecated Android function?

Advertisement