@SuppressWarnings vs @SuppressLint

There are actually two lints: one belongs to the compiler, so is Java-specific, and one belongs to Google and is Android-specific.

If your warning is about something in Java that isn't specific to Android, it's suppressed with @SuppressWarnings, and if it's Android-specific, it's suppressed with @SuppressLint.

Android Lint Warnings

Lint warnings are listed here: http://tools.android.com/tips/lint-checks

So let's say you have a warning about missing permissions, and the warning description starts off "This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs." In the lint warnings page linked above, we find this:

MissingPermission

Summary: Missing Permissions

Priority: 9 / 10 Severity: Error Category: Correctness

This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.

Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime.

So to suppress this, we put this annotation on the code:

@SuppressLint("MissingPermission")

Compiler Warnings

Let's say we find this warning:

"Unchecked cast: 'java.lang.Object' to 'java.lang.Integer' ..."

If you are reading this in hover popup in Android Studio, there is a More... link at the end. When you click the More... link, the text expands and you find this at the bottom:

"Hint: Pass -Xlint:unchecked to javac to get more details."

This tells you that you would use "unchecked" in the annotation like this:

@SuppressWarnings("unchecked")

For a list of compiler warnings, run javac -X:

C:\>javac -X
  -Xlint                     Enable recommended warnings
  -Xlint:{all,auxiliaryclass,cast,classfile,deprecation,dep-ann,divzero,empty,fallthrough,finally,options,overloads,overrides,path,processing,rawtypes,serial,static,try,unchecked,varargs,-auxiliaryclass,-cast,-classfile,-deprecation,-dep-ann,-divzero,-empty,-fallthrough,-finally,-options,-overloads,-overrides,-path,-processing,-rawtypes,-serial,-static,-try,-unchecked,-varargs,none} Enable or disable specific warnings
  .
  .
  .

Those are the values that you can use in @SuppressWarnings.


Also, there is @Suppress (kotlin.Suppress) which suppresses Android warnings as well as @SuppressLint.

For example, @Suppress("AlwaysShowAction").