title: Requesting Location Permission at Runtime
body: <p>I have a query implementing <code>RuntimePermission</code> for <code>Location</code>. When I tried to <code>requestLocationUpdates</code>, I got <code>LintError</code> suggesting me to add <code>PermissionCheck</code> for that line. Considering that I implemented run-time permissions. So this is how it looks,</p>
  
  <pre><code>if (isNetworkEnabled() &amp;&amp; networkListener != null) {
          if (ActivityCompat.checkSelfPermission(context,
                  Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp;
                  ActivityCompat.checkSelfPermission(context,
                          Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  
              ActivityCompat.requestPermissions(activity, new String[]
                      {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
  
          } else
              mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkListener);
  }
  </code></pre>
  
  <p>And my main class implements <code>onRequestPermissionsResult</code> callback. This looks like,</p>
  
  <pre><code>switch (requestCode) {
          case REQUEST_LOCATION:
                  if (grantResults.length == 2 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED
                          &amp;&amp; grantResults[1] == PackageManager.PERMISSION_GRANTED) {
                          mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkListener);
                  } else
                      Message.displayToast(context, "Without enabling permission, you can't access this feature");
              break;
      }
  </code></pre>
  
  <p>After the permission is granted, I request location updates again. But it again shows <code>LintError</code> to add the <code>PermissionCheck</code>. Refer the below image</p>
  
  <p><a href="https://i.stack.imgur.com/UdcWe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UdcWe.png" alt="enter image description here"></a></p>
  
  <p>Just for try I <code>checkSelfPermission</code> before requesting for <code>requestLocationUpdate</code> inside <code>onRequestPermissionsResult</code> and the error is gone. Like below code.</p>
  
  <pre><code>if (ActivityCompat.checkSelfPermission(context, permissions[0]) == PackageManager.PERMISSION_GRANTED &amp;&amp;
                              ActivityCompat.checkSelfPermission(context, permissions[1]) == PackageManager.PERMISSION_GRANTED)
  </code></pre>
  
  <p>So, my question is do I need to check the permission once again if the user granted the permission? Correct me if I'm wrong!</p>