title: Android Lint flagging NewAPI Error where it should not
body: <p>In my Android project I have <code>minSdkVersion</code> set to <code>19</code> and <code>targetSdkVersion</code> <code>26</code> in the manifest file. In one of the Java files I schedule an alarm using two different API's using an if statement for checking the current version of Android:</p>
  
  <pre><code>private void scheduleAlarm(AlarmManager alarmManager, long targetTime, PendingIntent pendingIntent, Intent intent) {
      if(VersionCheckUtils.isLollipopOrLater()) { // Lollipop is version 21
          // Code for versions after Lollipop
          logAlarm(targetTime, pendingIntent, intent, "Lollipop");
          alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(targetTime, pendingIntent),
                  pendingIntent);
      }
      else {
          // Code for older versions
          logAlarm(targetTime, pendingIntent, intent, "Kitkat");
          alarmManager.setExact(AlarmManager.RTC_WAKEUP, targetTime, pendingIntent);
      }
  }
  </code></pre>
  
  <p>Now Lint does not analyze the <code>if</code> statements and reports this error:</p>
  
  <pre><code>NewApi: Calling new methods on older versions
  ../../src/main/java/org/bee/beezone/trafficcontrol/AlarmScheduler.java:61: Call requires API level 21 (current min is 19): android.app.AlarmManager#setAlarmClock
  </code></pre>
  
  <p>How can you deal with this situation? The code should actually be safe, but Android lint does not seem to understand this.</p>
  
  <p>In the end I have deactivated "NewApi" checks by adding these lines to the gradle build file:</p>
  
  <pre><code>android {
      ...
      lintOptions {
          disable 'NewApi'
      }
  }
  </code></pre>
  
  <p>Is there a better way to deal with this type of situation?</p>