@kdowney @sengelman I was able to determine that his issue was caused by a bug present in both the example code and my app's code:
private void OnPermissionGranted(string permission)
{
grantedPermissions.Add(permission);
if (grantedPermissions.Count == requiredPermissions.Length)
{
StartAfterPermissions();
}
}
On the second connection attempt, if grantedPermissions
still contains the results from the first connection, StartAfterPermissions
will get executed multiple times in quick succession causing the wrong state error.
However, if we clear the grantedPermissions
before the second attempt, the second connection will be successful.