0

有人可以告诉我如何处理这种情况。Setting.System我知道使用 API 17,飞行模式的测试已从Settings.Global. 知道许多用户将在手机上使用较旧的 api,但想要正确处理弃用,我编写了以下方法:

@SuppressWarnings("deprecation")
public static boolean isAirplaneModeOn(Context context) {

    try {
        return Settings.Global.getInt(context.getContentResolver(),
          Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
    } catch (Exception e) {
        return Settings.System.getInt(context.getContentResolver(),
           Settings.System.AIRPLANE_MODE_ON, 0) != 0;
    }   
}

问题是在我的清单中,我将 minSDK 值设置为 9,这正是我想要的。冲突是然后我得到这个错误:

Call requires API level 17 (current min is 9)

处理这种情况的正确方法是什么?谢谢!

4

1 回答 1

1

检查用户的版本

if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLYBEAN){

}else{

}

然后只是抑制 lint 错误

于 2013-08-09T20:02:03.207 回答