title: Android Studio - remove Security Exception warning
body: <p>I'm getting the user's location through </p>
  
  <pre><code>Location location = LocationServices.FusedLocationApi.getLastLocation(
              mGoogleApiClient);
  </code></pre>
  
  <p>This line of code is inside a method and before calling this method I do check for Android run time permissions. Only if the permission is available from the user then I call this method. Code is working perfectly.</p>
  
  <p>The problem is that Android Studio still shows an error on this line not recognising that I've already checked before calling this function.</p>
  
  <pre><code>Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`
  </code></pre>
  
  <p>Now how do I remove this warning? I've already checked for permissions and don't want  to check again just to remove this warning. I've tried adding @SuppressWarnings() but don't know the exact String to pass into this.             <strong>@SuppressWarnings({"all"})</strong> works but it is obviously not recommended.</p>
  
  <p>How do I remove this warning? </p>
  
  <p><strong>EDIT 1 :</strong> This is my exact code -</p>
  
  <pre><code>private void checkPermissions() {
      if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
              == PackageManager.PERMISSION_GRANTED)
          getLocation();  //Method called if I have permission
  }
  
  private void getLocation() {
      //Android studio shows warning at this line.
      Location location = LocationServices.FusedLocationApi.getLastLocation(
              mGoogleApiClient);
  }
  </code></pre>
  
  <p>But if I put the permission check inside getLocation() method then the warning disappears. <strong>@SuppressWarnings({"MissingPermission"})</strong> did not work.</p>
  
  <p><strong>EDIT 2:</strong> I've discovered that the only way to suppress the warning are - </p>
  
  <p>Adding this comment on top of that particular piece of code - </p>
  
  <pre><code>//noinspection ResourceType
  </code></pre>
  
  <p>or adding this - </p>
  
  <pre><code>@SuppressWarnings({"ResourceType"})
  </code></pre>