1

I am trying to extend the SampleSync application. After I install the app, I can go to settings -> accounts & sync -> add account to add an account. However, if I want to check from my Application code and want to trigger AccountManager to add a new account directly, what should be the best way?

Paul de Vrieze
  • 4,888
  • 1
  • 24
  • 29
Sajid
  • 891
  • 2
  • 13
  • 24

1 Answers1

5

Ok, finally I got it working,

You can actually activate the AccountManager to add an account:

final AccountManager accountMgr = AccountManager.get(Main.this);
accountMgr.addAccount(Constants.ACCOUNT_TYPE, Constants.AUTHTOKEN_TYPE, null, null, Main.this, null, null);
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Sajid
  • 891
  • 2
  • 13
  • 24
  • What does the "Main.this" stand for!? – chris polzer Mar 07 '11 at 20:12
  • @chris, sorry I didn't put the full context. This code is in an anonymous inner class which sits in the Main.java class. From the inner class, you need to do Main.this to get a reference of the outer class. let me know if you need more details on this. – Sajid Mar 14 '11 at 02:10