1

What's the difference between -

AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

and

AccountManager accountManager =Accountmanager.get(context)

What should i use when-

1.Retrieving list of already created accounts in device

2.Adding my app's account to device

varmashrivastava
  • 432
  • 2
  • 6
  • 21

1 Answers1

2

If you look into Accountmanager.get(context) you'll see that it's basically a shortcut to first option with null check:

public static AccountManager get(Context context) {
    if (context == null) throw new IllegalArgumentException("context is null");
    return (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
}
Emil
  • 137
  • 1
  • 12