Log all user accounts and passwords?

别来无恙 提交于 2019-12-24 21:46:47

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8508748/log-all-user-accounts-and-passwords

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!