title: Android Annotation Working of @IdRes
body: <p>I was using <code>setId</code> method of <code>View</code> class. According to this method</p>
  
  <pre><code>public void setId(@IdRes int id) // This will accept resource id
  </code></pre>
  
  <p>When I tried to use this method with some hardcoded <code>int</code> value(let say 100), then this method start throwing correct warning which is expected-</p>
  
  <pre><code>actionButton.setId(100);
  </code></pre>
  
  <blockquote>
    <p>Expected resource of type id.</p>
  </blockquote>
  
  <p>But when I converted this hardcoded value into a method and never defined that this method will return <code>@IdRes</code>, Warning gets silent.</p>
  
  <pre><code>    private int getViewId() {
          return 100;
      }
  </code></pre>
  
  <p>Method call to set Id.</p>
  
  <pre><code> actionButton.setId(getViewId());
  </code></pre>
  
  <p>Isn't both are same. Hardcoded <code>int</code> and a <code>int</code> return from this method. So why in one case method throwing warning and in another it gets silent.</p>
  
  <p>For a sake I tried with <code>StringRes</code> but I am getting warning in both cases.</p>
  
  <pre><code> private void setMyString(@StringRes int resourceString) {}
  </code></pre>
  
  <p>Warning in both below cases-</p>
  
  <pre><code>    setMyString(1);
      setMyString(getStringId()); getStringId returns int value
  </code></pre>