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) {
    // ......
}