locked
Null allowableAccounts arg AccountManager.NewChooseAccountIntent causes exception in Xamarin 4.8 RRS feed

  • Question

  • User3975 posted

    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.

    Monday, July 29, 2013 2:42 PM

All replies

  • User30116 posted

    Did you find a solution to this problem ?

    Tuesday, November 26, 2013 7:06 PM
  • User30116 posted

    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);

    Tuesday, November 26, 2013 7:21 PM
  • User5822 posted

    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

    Tuesday, November 26, 2013 7:31 PM
  • User3975 posted

    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)

    Tuesday, November 26, 2013 7:49 PM