title: How to call function right after getting permissions?
body: <p>After starting my application, I ask user for permissions with this function:</p>
  
  <pre><code>protected void requestPermission(){
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
              requestPermissions(PERMISSIONS, 100);
          }
      }
  </code></pre>
  
  <p>I need to set checkboxes true or false right after getting user permissions, but if I call functions this way:</p>
  
  <pre><code>requestPermission();
  setCheckboxStates();
  </code></pre>
  
  <p>function <code>setCheckboxStates()</code> activates before getting all the permissions. I could partly solve this problem with using <code>Thread.sleep()</code> but it doesn't work all the time and sometimes look weird.</p>
  
  <p>How is it possible to call function <code>setCheckboxStates()</code> right after <code>requestPermission()</code> function finishes asking user for permissions?</p>