當試圖從客戶經理獲得的Gmail用戶名和密碼,會出現以下異常:錯誤在獲取用戶名和密碼
java.lang.SecurityException: caller uid 10073
比不同的認證的UID
AccountManager accountManager = AccountManager.get(mContex);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(mContex).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
String possiblePassword = accountManager.getPassword(account) ;
System.out.println("User name :- "+possibleEmail);
System.out.println("User Password :- "+possiblePassword);
}
}
中的Manifest.xml添加權限:
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.USE_CREDENTIALS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
有關如何解決此異常的任何想法?
發佈您的帳戶驗證程序xml和您的類AuthenticatorService。 – Rahul
有人已經發布了類似的東西http://stackoverflow.com/questions/3403885/securityexception-in-getpassword-of-accountmanager-in-android –
它不可能獲得密碼。我們將獲得用戶名 – User