變動時監聽方式
1.Class要implements OnAccountsUpdateListener
2.Class要實做onAccountsUpdated
3.註冊Listener
AccountManager.get(context).addOnAccountsUpdatedListener(this, null, false);
取得系統的Account List
Account[] accounts = AccountManager.get(context).getAccounts();
int newAccountsLength = accounts.length;
Account[] newAccounts = new Account[newAccountsLength];
for (int i = 0; i < accounts.length; i++) {
Account mAccount = new Account(accounts[i].name, accounts[i].type);
newAccounts[i] = mAccount;
}
沒有留言:
張貼留言