Mark D
Mark D

Reputation: 1329

Log all user accounts and passwords?

This is strictly for testing purposes. I am not building this into an application.

I am trying to log all the user's saved accounts and passwords

    AccountManager accountManager = AccountManager.get(this);   

    for(Account account : accountManager.getAccounts())
    {
        System.out.println(account.name + " : " + accountManager.getPassword(account));
    }

But I am getting an error

E/AndroidRuntime(11944): java.lang.SecurityException: caller uid XXXXX is different than the authenticator's uid

I have read this question but it doesn't really explain how to get around this problem, just to avoid it, at least I think so.

Is there a way around this issue?

Thanks in advance

Upvotes: 0

Views: 332

Answers (1)

sabadow
sabadow

Reputation: 5161

This happend because you can't obtain the accounts of a device at this way. This only works if you previously add an account to the AccountManager, and you want retrieve it later.

That's the reason why is telling you that haven't got the right permission.

To know the accounts added in the device should use, for example:

AccountManager accountManager = AccountManager.get(this);
Account[] accounts = accountManager.getAccounts();
accountManager.getUserData(accounts[0], AccountManager.KEY_USERDATA);

Hope it helps.

Upvotes: 2

Related Questions