title: How to request a permission from a Service
body: <p>I am trying to request a permission on my <strong>Service</strong>. Usually to request a permission I have to pass an Activity. My application does not have an <code>Activity</code>.</p>
  
  <pre><code>// Here, thisActivity is the current activity
  if (ContextCompat.checkSelfPermission(thisActivity,
                  Manifest.permission.READ_CONTACTS)
          != PackageManager.PERMISSION_GRANTED) {
  
      // Should we show an explanation?
      if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
              Manifest.permission.READ_CONTACTS)) {
  
          // Show an explanation to the user *asynchronously* -- don't block
          // this thread waiting for the user's response! After the user
          // sees the explanation, try again to request the permission.
  
      } else {    
          ActivityCompat.requestPermissions(thisActivity,
                  new String[]{Manifest.permission.READ_CONTACTS},
                  MY_PERMISSIONS_REQUEST_READ_CONTACTS);
      }
  }
  </code></pre>
  
  <p>How can I do it from a Service?</p>