title: What makes different permission request position in code change android app behaviour
body: <p>I am developing an Android app that downloads data from Firestore using different <code>object</code> classes and needs user position access permission.
  I have a function in <code>object FirestoreDowloader</code> class that is resposible of downloading from Firestore:</p>
  <pre><code>fun getCollection(
          collectionPath: Collections,
          checkSignature: Boolean = true,
          onCompletion: (ArrayList&lt;Map&lt;String, Any&gt;&gt;, ReadingError?) -&gt; (Unit)
      ) {
  
          val result = ArrayList&lt;Map&lt;String, Any&gt;&gt;()
          if (DeviceManager.isConnected()) {
  
              val collectionReference = db.collection(&quot;/&quot; + collectionPath.value)
              val query = if (checkSignature)
                  collectionReference.whereEqualTo(signatureField, signature)
              else
                  collectionReference
  
              query.get()
                  .addOnSuccessListener { querySnapshot -&gt;
  
                      //do stuff
                      onCompletion(result, null)
                  }
                  .addOnFailureListener {
                      onCompletion(
                          ArrayList(),
                          ReadingError.NOT_AUTHENTICATED
                      )
                  }
          } else
              onCompletion(ArrayList(), ReadingError.DISCONNECTED)
      }  
  </code></pre>
  <p>that is called by three different <code>object</code> classes.
  One of them downloads a list of elements to be displayed in a <code>RecyclerView</code>
  Before adding the position permission request the app worked pretty well, but now I am facing different problems:</p>
  <ol>
  <li>the <code>onCompletion</code> lamdba is apparently not called, hence the app can't store what is downloaded</li>
  <li>if I don't grant the position permission the app doesn't show the downloaded list in the <code>RecyclerView</code></li>
  <li>If I grant the position permission the app shows the downloaded list, but if I go to settings to revoke the permission in my phone without closing the app and then reopen it, I see an empty  <code>RecyclerView</code>.</li>
  </ol>
  <p>I found a temporary solution so far: if I place the request permission at the end of all downloads the app works fine, but I this can't be the final solution because the app should work regardlessly of the the request permission position.</p>
  <p>Can that be caused by some thread conflicts?</p>