title: Android runtime permissions- how to implement
body: <p><a href="http://developer.android.com/training/permissions/requesting.html" rel="noreferrer">Android Developer Documentation</a> gives this example of requesting permissions at runtime:</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 expanation 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 {
  
          // No explanation needed, we can request the permission.
  
          ActivityCompat.requestPermissions(thisActivity,
                  new String[]{Manifest.permission.READ_CONTACTS},
                  MY_PERMISSIONS_REQUEST_READ_CONTACTS);
  
          // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
          // app-defined int constant. The callback method gets the
          // result of the request.
      }
  }
  </code></pre>
  
  <p>What is "MY_PERMISSIONS_REQUEST_READ_CONTACTS" in this example? It says it's an app-defined int constant, but does that mean I should make a Constants.java and declare a public static int? What should the value be?</p>
  
  <p>In other examples I see people use 1 here, or 0 or 0xFFEEDDCC, but I can't find an explanation of what it is. Can someone explain to me what needs to go here and why? (In my case, I need to make sure the app has permission to access fine location)</p>
  
  <p>The ActivityCompat documentation says "Application specific request code to match with a result reported to onRequestPermissionsResult"? This does not help me.</p>