Null allowableAccounts arg AccountManager.NewChooseAccountIntent causes exception in Xamarin 4.8

The following code results in an ArgumentNullException (full logcat output attached) since upgrading to Xamarin.Android 4.8. I have double checked and exactly the same code running on exactly the same devices works perfectly fine when compiled against a prior version of Xamarin.Android.

var intent = AccountManager.NewChooseAccountIntent(
    _activeAccount,
    null, // allowableAccounts, optional, but now causes exception if null
    new[] { Authenticator.AccountType },
    true,
    null,
    Authenticator.OAuth2TokenType,
    null,
    null);

activity.StartActivityForResult(intent, requestCode);

I can also confirm that the error does not occur if a non-null, non-empty Account[] array is provided for the ‘allowableAccounts’ parameter--but this results in filtering which is not the desired behaviour in our case.

Posts

  • Did you find a solution to this problem ?

  • DavideMendoliaDavideMendolia USMember
    edited November 2013

    It's a little annoying but I used this.

    Intent intent = AccountPicker.NewChooseAccountIntent(null, AccountManager.Get(this).GetAccounts(), new String[]{"com.google"}, false, null, null, null, null);

  • I previously ran into several other issues involving bindings that use various collection types as arguments.

    https://bugzilla.xamarin.com/show_bug.cgi?id=15891

  • Davide:

    I worked around the problem in essentially the same way as you did, the only exception being that I used AccountManager.GetAccountsByType() (obviously the end result is the same since the third parameter filters the account by type anyway).

    T.J.Purtell:

    I wasn't using any other APIs with collection parameters at the time, but it did look to me like a general regression in the SDK bindings in that release of Xamarin.Android (4.8) since there's nothing in the release notes that suggests this particular method would have changed in any way (and the same code compiled with an older version of Xamarin.Android on exactly the same device works correctly)

Sign In or Register to comment.