iex
03/02/2020, 8:26 PMlouiscad
03/02/2020, 9:01 PMiex
03/02/2020, 9:53 PMTolriq
03/03/2020, 7:37 AMiex
03/05/2020, 7:34 AMTolriq
03/05/2020, 7:43 AMlouiscad
03/05/2020, 8:32 AMTolriq
03/05/2020, 8:41 AMlouiscad
03/05/2020, 10:54 PMTolriq
03/06/2020, 8:35 AMlouiscad
03/06/2020, 8:43 AMensurePermission
function is suspending. You're supposed to call it from a scope that is cancelled with the lifecycle. That means when your activity is recreated, if the permission prompt is still visible and the user grants it just after, you'll not know, so you'll ask again (for example when the user clicks the button), and here, you'll see the permission has been granted. Android makes it impossible for developers to provide a better UX without adding another layer of spaghetti code, to remember that you were requesting a permission that you might get the callback from, maybe, if you're not falling into the case of empty permission request result where the activity is no longer able to request permissions and you need a new one.
So, I'm encouraging you to test the sample in Splitties permissions, because that way, you can witness the UX that users get in the very rare case of activity being destroyed while requesting a permission, and you can see how the library ensures your app can continue to work and request the permission again if needed, or pass when granted.Tolriq
03/06/2020, 8:55 AMlouiscad
03/06/2020, 9:09 AMTolriq
03/06/2020, 9:15 AMlouiscad
03/06/2020, 10:05 AMensurePermission
. Also, you can remember you were requesting a permission using saved state, and call ensurePermission
and the rest again on activity recreation. Now that AndroidX saved state is stable, I might try that in the sample when I'm done with way more important things.Tolriq
03/06/2020, 10:21 AM