Skip to content

SuppressWarnings

使用SuppressWarnings

在AS中取消警告。常见的有

@SuppressWarnings("all")
@SuppressWarnings("unchecked")
@SuppressWarnings({"JavaDoc"})
@SuppressWarnings({"UnusedDeclaration"})
@SuppressWarnings({"UnusedParameters"})
@SuppressWarnings({"FieldCanBeLocal"})
@SuppressWarnings("StringEquality")

参考: http://kurrytran.blogspot.com/2014/05/android-studio-list-of-suppress-warning.html

Android中和EventBus结合起来用

// 用于注解
public static final String TAG_UNUSED_DECLARE = "UnusedDeclaration"; // declare

/**
 * @param event 数据
 */
@SuppressWarnings({TAG_UNUSED_DECLARE})
@Subscribe(threadMode = ThreadMode.MAIN)
public void onXXXEvent(XXXEvent event) {
    // ......
}

作者: RustFisher
联系: rf.cs@foxmail.com
博客: rustfisher.com | RustFisher cnblog
示例: AndroidTutorial Gitee, Tutorial Github
链接: https://www.an.rustfisher.com/android/as/suppress-warnings-use/
一家之言,仅当抛砖引玉。如有错漏,还请指出。